I am new to Quartz and I’m running into a compiling error. I am simply trying to get the HelloJob to run based on Quartz’s Lesson 1 for Hello World. I am having trouble declaring a JobDetail with the error: The method newJob(Class<? extends Job>) in the type JobBuilder is not applicable for the arguments (Class)”.
Originally, the code had 3 errors at newJob, newTrigger, and simpleSchedule was
// define the job and tie it to our HelloJob class
JobDetail job = newJob(HelloJob.class)
.withIdentity("job1", "group1")
.build();
// Trigger the job to run now, and then repeat every 40 seconds
Trigger trigger = newTrigger()
.withIdentity("trigger1", "group1")
.startNow()
.withSchedule(simpleSchedule()
.withIntervalInSeconds(40)
.repeatForever())
.build();
without JobBuilder.newJob(…), TriggerBuilder.newTrigger(…), SimpleScheduleBuilder.simpleSchedule(…). Unlike the example given, I went ahead and added the imports and attached the class calls in front of newJob, newTrigger, etc. which got rid of 2/3 errors. But it seems the error persists with
JobDetail job = JobBuilder.newJob(HelloJob.class)
.withIdentity("job1", "group1")
.build();
I have also tried replacing my job declaration with
JobDetail job = new JobDetail("job1", "group1", HelloJob.class);
but that ends with Cannot instantiate the type JobDetail and it seems like a few examples out there do this.
Will really appreciate clarification,
Thanks!
You need to have this line of code:
And then in should work. Hopefully.
Edit:
AND MAKE SURE ‘HELLOJOB’ IMPLEMENTS JOB!!
There.