Software Development

How to use Quartz in a simple Java application

Some applications need some sort of background processes that support some aspect of a business process. This article demonstrates how to use Quartz in a simple Java application.

Software Environment

  • Windows 7 Professional SP1
  • Eclipse – Kepler Release
  • Java 1.7 (1.7.0_67 – Windows x86)
  • Quartz 2.2.1
    • Reference these jar files
      1. quartz-2.2.1.jar
      2. quartz-jobs-2.2.1.jar
  • Log4j
    • Reference this jar file
      1. log4j-1.2.16.jar
  • SLF4J 1.6.6
    • Reference these jar files
      1. slf4j-api-1.6.6.jar
      2. slf4j-log4j12-1.6.6.jar

Your log4j.xml

Yet again, log4j.xml appears. You may use your own configuration or use the file on How to configure Log4j to log to the console. As usual, make this file available in the classpath.

Java Codes

We have two classes. The MainClass starts up the scheduler, and HelloWorldJob is the task we want to execute repeatedly at an interval.

Sample Output


Download the Project

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.

You Might Also Like