Windows Scheduler + Java Task

Reference :

http://stackoverflow.com/questions/12034177/running-a-java-program-as-a-scheduled-task

http://bbs.csdn.net/topics/300191012

http://devinsun.iteye.com/blog/454350

 

Requirement:

For testing, need to send some transactions during midnight.

Testing program(java) is ready, the thing is how to schedule it to run at midnight.

Tools to use :

1) Windows Scheduler

2)Eclipse and Jar file exportation

 

Steps:

1.In Eclipse, Export java project (having main class with main method) to a jar

1) following the pic as below , same steps as mentioned in :http://devinsun.iteye.com/blog/454350

2) things to note is the MANIFEST.MF , mine is like below (there is 2 blank lines in the end of the file, no verifying ...:))

Manifest-Version: 1.0

Main-Class: com.gb.term.simulator.main.TxRateRequestSimulatorTest

Class-Path: lib/log4j-1.2.16.jar lib/commons-codec-1.4.jar lib/commons-lang3-3.1.jar lib/contiperf-2.3.0.jar lib/jpos.jar lib/slf4j-api-1.6.1.jar lib/slf4j-log4j12-1.6.1.jar

 

3)after generate the jar , structure like this :

3. firstly, try to create a cmd file to call jar file : runScript.cmd, this can run independently. But when setup in Windows scheduler and the scheduled time is due, the cmd prompt window just flashed without running the logic inside. No time to investigate ,just give up

@echo off
REM Eventually change directory to the program directory
cd D:\Working\JarWork\
REM run the program
"C:\Program Files\Java\jdk1.7.0_21\bin\java.exe" -jar "TXRateRequestSimulatorTest.jar"

 

4.Second try by following : http://www.coderanch.com/t/570071/gc/schedule-jar-file-windows-task

Program/script:  "C:\Program Files\Java\jdk1.7.0_21\bin\java.exe"
Arguments: -jar  D:\Working\JarWork\TXRateRequestSimulatorTest.jar
Start in (optional):C:\Users\xding\Desktop   (note: this is optional, if  there is log, maybe log will be show in this path if no special config)

 

DONE!!  ^_^

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值