Brief Introduction:
Quartz provides job scheduling service, can be used in Java programs, try this here.
Reference (Http://www.quartz-scheduler.org/documentation/quartz-2.2.x/quick-start)
steps:
1. Download
Http://www.quartz-scheduler.org/downloads/catalog
2. After the decompression, the Lib folder under the content, put the project under the class path
There are these libraries, all added to the path.
2. Establish the Quartz profile quartz.properties
Org.quartz.scheduler.instanceName = Myscheduler
org.quartz.threadPool.threadCount = 3
Org.quartz.jobStore.class = Org.quartz.simpl.RAMJobStore
Add Log4j.xml
<?xml version= "1.0" encoding= "UTF-8"?> <!
DOCTYPE log4j:configuration SYSTEM "Log4j.dtd" >
<log4j:configuration xmlns:log4j= "http://" jakarta.apache.org/log4j/">
<appender name=" Default "class=" Org.apache.log4j.ConsoleAppender ">
<param name= "target" value= "System.out"/> <layout class=
"Org.apache.log4j.PatternLayout" >
<param name= "Conversionpattern" value= "[%p]%d{dd MMM. SSS AA}%t [%c]%n%m%n%n "/>
</layout>
</appender>
<logger name=" Org.quartz ">
<level value= "info"/>
</logger>
<root>
<level value= "info"/>
< Appender-ref ref= "Default"/>
</root>
</log4j:configuration>
Code:
Package COM.ANIALY.TQ;
Import Org.quartz.Scheduler;
Import org.quartz.SchedulerException;
Import org.quartz.impl.StdSchedulerFactory;
public class Testquartz {
private static Scheduler Scheduler;
public static void Main (string[] args) {
try {
//Grab The Scheduler instance from the Factory
= STD Schedulerfactory.getdefaultscheduler ();
and start it off
Scheduler.start ();
Scheduler.shutdown ();
} catch (Schedulerexception se) {
se.printstacktrace ();}}}
Output: