Results 1 to 8 of 8
- 11-11-2007, 12:25 AM #1
Member
- Join Date
- Nov 2007
- Posts
- 3
- Rep Power
- 0
how to run java app on windows in a cron like on unix
I am trying to run a java program every 10 minutes on my windows PC. If I run the program manually all works fine...
java myProgramName
Since windows does not support crontab type functionality, I have installed pycron and it runs my program every ten minutes, but I get a class not found error.
I have tried
0,10,20,30,40,50 * * * * javaw myPackage.com.myProgram
I have added my program to the system environment variable CLASSPATH, but still no success.
Any thoughts on how I can set up cron on windows to run my java application?
Thanks in advance for your assistance
Dean-O
- 11-11-2007, 12:42 AM #2
Try to create a bat file. Set JAVA_BIN path there and call interpreter with full path in the bat file (e.g. $JAVA_BIN$\java.exe YourClass) Test it by running bat file manually and then try to run bat file via cron.
- 11-11-2007, 01:23 AM #3
Member
- Join Date
- Nov 2007
- Posts
- 3
- Rep Power
- 0
I have tried the bat file option too, but I get the same class not found error ir I run the bat file from the pycron. If I run the bat file manually, all is fine. Maybe it has to do with pycron... it is an NT service that is running as local system administrator... maybe the user does not get the CLASSPATH variable...
How would one run a java application on a windows machine in a crontab like manner as one would on a unix box?
Thanks
Dean-O
- 11-11-2007, 10:04 AM #4
Can you post the bat file you created? I am not sure if you set classpath variable too in your bat file.
- 11-11-2007, 05:36 PM #5
Member
- Join Date
- Nov 2007
- Posts
- 3
- Rep Power
- 0
javaw.exe -Xmx300m -classpath ".;C:\MailProgram;C:\Program Files\Java\jre1.5.0_06\lib\ext\mail.jar;C:\Program Files\Java\jre1.5.0_06\lib\ext\activation.jar" myapps.com.showMail
- 11-11-2007, 06:09 PM #6
My suggestion is to define CLASSPATH as an environment variable and JAVA_BIN path inside bat file before calling and javaw.exe. I have Vista and i dont have CLASSPATH environment variable. But as far as i remember, in XP and below there was a globally defined CLASSPATH environment variable. Sorry if i remember wrongly.
- 05-23-2008, 07:15 AM #7
I suggest that you try using a thread. You can set the thread to sleep for 10 minutes i.e Put the main class in an endless loop and put the thread in that loop.
Thread.sleep(600000).
After that you can add its exe jar file to the start-up programs so thats its launched on every log-on or when the computer starts up.
try it out...
- 05-23-2008, 01:39 PM #8
Windows supports cron like functionality. It is called Task Scheduler. Go to Control Panel/Scheduled Tasks and there you can specify when your program should run. Keep in mind to provide the password for the user your task will impersonate.
Daniel @ [www.littletutorials.com]
Language is froth on the surface of thought
Similar Threads
-
Accessing unix system using java
By abhishek.sinha in forum AWT / SwingReplies: 3Last Post: 06-19-2008, 08:05 AM -
Filter a file in java (unix cut command equivalent)
By marcosabel in forum New To JavaReplies: 0Last Post: 02-11-2008, 07:26 PM -
How do I update a WINDOWS user env variable from my java code ?
By gavman99 in forum Advanced JavaReplies: 0Last Post: 02-06-2008, 02:07 PM -
Running java program with arguments in Unix"
By gvi in forum Advanced JavaReplies: 2Last Post: 11-08-2007, 07:01 PM -
Help with windows in java
By lenny in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 06:22 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks