Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-11-2007, 01:25 AM
Member
 
Join Date: Nov 2007
Posts: 3
rockie12 is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-11-2007, 01:42 AM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-11-2007, 02:23 AM
Member
 
Join Date: Nov 2007
Posts: 3
rockie12 is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-11-2007, 11:04 AM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
Can you post the bat file you created? I am not sure if you set classpath variable too in your bat file.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-11-2007, 06:36 PM
Member
 
Join Date: Nov 2007
Posts: 3
rockie12 is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 11-11-2007, 07:09 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 05-23-2008, 08:15 AM
dowell's Avatar
Member
 
Join Date: May 2008
Posts: 6
dowell is on a distinguished road
Quote:
Originally Posted by rockie12 View Post
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

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...
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 05-23-2008, 02:39 PM
danielstoner's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Canada
Posts: 183
danielstoner is on a distinguished road
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 @ [
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
]
Language is froth on the surface of thought
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing unix system using java abhishek.sinha AWT / Swing 3 06-19-2008 09:05 AM
Filter a file in java (unix cut command equivalent) marcosabel New To Java 0 02-11-2008 08:26 PM
How do I update a WINDOWS user env variable from my java code ? gavman99 Advanced Java 0 02-06-2008 03:07 PM
Running java program with arguments in Unix" gvi Advanced Java 2 11-08-2007 08:01 PM
Help with windows in java lenny AWT / Swing 1 08-07-2007 07:22 AM


All times are GMT +3. The time now is 12:57 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org