1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2010
    Rep Power

    Cronjob for a executing a single method of Java class

    Am a new bie to Java, Currently we are running a daily cronjob of executing a class (a struts2 web application project) which sends an email to two different team @ a specific time. The class includes two methods, one for sending email to sales team, and other for sending email to business team of the list of created keywords on the site that day. The requirement is to send an email to sales team @ a different time, and to business team to other team. So, can i write cron jobs by specifying the method name, so that only that specific method will be executed @ that time.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Adelaide, AU
    Rep Power

    A cron job cannot execute a single method within a Java class file because it's not designed for this. Cron jobs simply execute a command at a given time or interval with any additional parameters specified in the command line. I guess based on this, you could create a separate driver class which executes the single method, or otherwise you could create some form of parameter input which has a condition to run the single method.

    I'm no Java expert, but I'm pretty sure that's the way to go.



IMN logo majestic logo threadwatch logo seochat tools logo