Chènevis Chènevis - 1 year ago 120
Java Question

Java Quartz 2.2.2 missing method

I’m trying to create a task scheduler. I use Quartz. I followed this example.
I make the dependence in maven (tested 2.2.1 and 2.2.2) and my class HelloJob implements Job.

I have

public class HelloJob implements Job{
public void execute(JobExecutionContext context) throws JobExecutionException {
// Say Hello to the World and display the date/time
System.out.println("Hello World! - " + new Date());

JobDetail job = newJob(HelloJob.class)
.withIdentity("job1", "group1")


But I have the message:

The method newJob(Class<HelloJob>) is undefined for the type HelloJob

I tried to put the JobDetail declaration in my SimpleExample class, but the same error appears...

Answer Source

The method newJob is defined in org.quartz.JobBuilder as static. Add an static import in your class:

import static org.quartz.JobBuilder.*;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download