Reputation: 1333
I am just starting to learn Quartz scheduling and in the first step of it I am facing problems.
I am looking at the examples of it on its main website but when I am trying to develop it in my workspace it is giving me errors.
package testing.quartz.scheduler;
import java.util.Date;
import java.util.logging.Logger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.Trigger;
import org.quartz.impl.StdSchedulerFactory;
public class TesterMain {
/**
* @param args
*/
public void run() throws Exception {
// First we must get a reference to a scheduler
SchedulerFactory sf = new StdSchedulerFactory();
Scheduler sched = sf.getScheduler();
// computer a time that is on the next round minute
Date runTime = evenMinuteDate(new Date());<--Here its giving me error
// define the job and tie it to our HelloJob class
JobDetail job = newJob(HelloJob.class)<--Here its giving me error
.withIdentity("job1", "group1")
.build();
// Trigger the job to run on the next round minute
Trigger trigger = newTrigger()<--Here its giving me error
.withIdentity("trigger1", "group1")
.startAt(runTime)
.build();
// Tell quartz to schedule the job using our trigger
sched.scheduleJob(job, trigger);
// Start up the scheduler (nothing can actually run until the
// scheduler has been started)
sched.start();
// wait long enough so that the scheduler as an opportunity to
// run the job!
try {
// wait 65 seconds to show job
Thread.sleep(65L * 1000L);
// executing...
} catch (Exception e) {
}
// shut down the scheduler
sched.shutdown(true);
}
public static void main(String[] args) throws Exception {
TesterMain example = new TesterMain();
example.run();
}
}
I have specified places where its giving me compilation error. Telling these method is not there in your class.
So I am wondering are these methods really valid (newTrigger, newJob, evenMinuteDate).
I am totally confused. I have added all the jars which is required.
Upvotes: 0
Views: 5265
Reputation: 440
import static org.quartz.JobBuilder.newJob;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
import static org.quartz.TriggerBuilder.newTrigger;
import static org.quartz.DateBuilder.evenMinuteDate;
Import these classes to your class.
Upvotes: 1
Reputation: 1541
It doesn't compile, because you forgot to import the right classes. This probably fixes it:
import static org.quartz.DateBuilder.*;
import static org.quartz.JobBuilder.*;
import static org.quartz.TriggerBuilder.*;
Upvotes: 6
Reputation: 2286
Date runTime = evenMinuteDate(new Date());
The evenMinuteDate
method is not declared anywhere.
JobDetail job = newJob(HelloJob.class);
The HelloJob class is not imported and missing a space between new
and Job
Trigger trigger = newTrigger()
You're missing a space between new
and Trigger()
Upvotes: 0