• Post Reply Bookmark Topic Watch Topic
  • New Topic

scheduling a Java jar  RSS feed

 
Balabo Haeron
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A script was put together that I would now like to schedule to run daily in Windows. I am using schtasks.

I have encountered some problem using schtasks for Java jar files - it does not accept "-jar" extension in the commandline, i.e. the following generates an error

schtasks /create /tn "daemon task" /tr java -jar c:\files\javaapplication.jar /sc daily /st 08:30

ERROR: Invalid argument/option '-jar'

So I tried the following -

schtasks /create /tn "daemon task" /tr "java -jar c:\files\javaapplication.jar" /sc daily /st 08:30

The above does not generate an error however - it does not appear to work as there is output.

How would we go about scheduling a "java -jar %%%%&" task in windows?
 
Balabo Haeron
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really what I am looking for - any suggestions? Or can someone suggest alternative means to schedule java routines on a windows machine
 
Tomas Linhart
Ranch Hand
Posts: 86
2
Java Ubuntu VI Editor
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about to encapsulate the command in a batch file and schedule the batch file then?
 
Balabo Haeron
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes - I tried placing the java command in a batch file but it generated it's own error. I placed the following in a batch file,

java -jar c:\files\javaapplication.jar

And placed the batch within the schedule command,

schtasks /create /tn "daemon task" /tr java -jar "c:\_daily\sch_batch.bat" /sc daily /st 08:30

If I click directly on the batch file outside of the scheduler, it runs the routine. However, if the same code is called from within schtasks I get the following error,

java.io.IOException : Access is denied
at java.io.WinNTFileSystem.createFileExclusively(Native Mode)
at java.io.File.createNewFile(UnKnown Source)

I attempted to edit the schtasks expression so that it would run the tasks as an administrator - this didn't seem to yield much either
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!