Skip to content
Advertisement

Trying to make a daily job schedule with quartz in java

I’m working on a Discord Bot with should do sth every day. I tried using the Quartz library for it, but the job is never executed. Below is the code I use for testing:

JavaScript

The job is never called. Can some tell me what I did wrong?

Greetings, Martin.

Advertisement

Answer

  1. You called your class job(small letter), but used in JobBuilder Job.class (with big letter) – it’s an interface of org.quartz. . Call your class like – StartMyBotJob to avoid this, or print JobBuilder.newJob(job.class)
  2. Make your job class separately(in another file) from your class OR make it public (visible for creation by another object) and static (if nested class is not static it depends from the QuartzTestClass, and require it’s instance to create object. See more – https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html)

This version should work:

JavaScript
Advertisement