Software Development

How to use Quartz in a simple Java application

java Sort Enum Properties Monitor Directory File Lambda Expression parameter return types Validate XML String XSD ExecutorService AutoCloseable Try-With-Resources Convert LocalDateTime OffsetDateTime Run Codes Before Shutdown XML Tag Lambda PostgreSQL JDBC invoke JavaScript Applet SFTP Batch hang block main thread MySQL JDBC try-with-resources delete Unencrypted SoapFault Apache CXF Remove XML Element XSLT skip execute finally public static void main constructor fields Eclipse convert Iterator Stream StreamSupport XMLEncoder XMLDecoder rename P6Spy JDBC Example PDF Version JasperReports Run from Ant iReport Page Numbers Count entities persistence context hibernate

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

quartz_output-001

Download the Project

https://www.dropbox.com/s/wo2ov9yjrnjef17/QuartzAppTurretaDotCom.zip?dl=0

Got comments, or suggestions? Please visit our Facebook page!

You Might Also Like