wood burning stoves 2.0*
The moose likes Java in General and the fly likes JAR file runs when double-clicked, but not via Task Scheduler? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "JAR file runs when double-clicked, but not via Task Scheduler?" Watch "JAR file runs when double-clicked, but not via Task Scheduler?" New topic
Author

JAR file runs when double-clicked, but not via Task Scheduler?

James Brooks
Gunslinger
Ranch Hand

Joined: Aug 17, 2006
Posts: 165
Hi all,

OK, so, I have my JAR file on a WS2003 machine, and when I double-click on the JAR or run it from the command line, my program executes just fine. The JAR is on the root of my C drive; C:\CMMS_SCADA.jar. I've created a daily scheduled task for this JAR, and when the clock rolls around to its execution time, the task status shows as 'running', but the program does not run. The scheduler is scheduled to run:

"C:\Program Files\Java\jdk1.6.0_13\jre\bin\java.exe" -jar "C:\CMMS_SCADA.jar"

and start in:

"C:\Program Files\Java\jdk1.6.0_13\jre\bin"

Am I missing something?

Thanks in advance, as always.


Hello. My name is Inigo Montoya. You killed my father. Prepare to die.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18886
    
    8

What makes you think the program doesn't run? Perhaps it does run but the results of its running weren't what you expected.
James Brooks
Gunslinger
Ranch Hand

Joined: Aug 17, 2006
Posts: 165
Hi Paul,

The program creates a .csv file. When run manually, the .csv is output, which I can tell from the file attributes (time created). It does not output the file when the task scheduler supposedly runs it.

Paul Clapham wrote:What makes you think the program doesn't run? Perhaps it does run but the results of its running weren't what you expected.
adeeb alexander
Ranch Hand

Joined: May 29, 2008
Posts: 268
Try using the AT command.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18886
    
    8

James Brooks wrote: The program creates a .csv file. When run manually, the .csv is output, which I can tell from the file attributes (time created). It does not output the file when the task scheduler supposedly runs it.

No, that just tells you that it didn't work right. You know the task scheduler ran it, so presumably something bad happened and the program crashed. That suggests to me that something is different between your environment and the task scheduler's environment.

By the way, you said it worked correctly when you ran it from the command line. Does it work correctly when you run it from the command line with C:\Program Files\Java\jdk1.6.0_13\jre\bin as the current directory, or did you try it with some other current directory?

And does the command line run the application under your user profile or some other user profile. Could that make a difference?

I'm sure there are plenty of other environment differences that could exist. Keep looking for them.
James Brooks
Gunslinger
Ranch Hand

Joined: Aug 17, 2006
Posts: 165
OK, thanks for the help :-) I changed the task scheduler's profile for that task to my domain admin login, and voila! I was confused because that username is the same for the local machine and the domain. Now, I'm getting that silly mail messaging exception (class not found) again when it runs, but only when either the task scheduler runs it, or when I navigate to the directory you named below and run it from there. Any thoughts? It apparently has to do with the mail.jar file. I did a search for mail.jar on the entire computer, and got quite a few results. See screenshot of search results if you like; I have a feeling that this a .jar file placement problem, or maybe it is in a directory it should not be and is causing a conflict.

Paul Clapham wrote:
James Brooks wrote: The program creates a .csv file. When run manually, the .csv is output, which I can tell from the file attributes (time created). It does not output the file when the task scheduler supposedly runs it.

No, that just tells you that it didn't work right. You know the task scheduler ran it, so presumably something bad happened and the program crashed. That suggests to me that something is different between your environment and the task scheduler's environment.

By the way, you said it worked correctly when you ran it from the command line. Does it work correctly when you run it from the command line with C:\Program Files\Java\jdk1.6.0_13\jre\bin as the current directory, or did you try it with some other current directory?

And does the command line run the application under your user profile or some other user profile. Could that make a difference?

I'm sure there are plenty of other environment differences that could exist. Keep looking for them.


[Thumbnail for Untitled.gif]

James Brooks
Gunslinger
Ranch Hand

Joined: Aug 17, 2006
Posts: 165
Also, is there a good resource to learn about the different paths within the JRE/JDK directories? I'm still clueless about this part of it.
James Brooks
Gunslinger
Ranch Hand

Joined: Aug 17, 2006
Posts: 165
Bump
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JAR file runs when double-clicked, but not via Task Scheduler?