Help coderanch get a
new server
by contributing to the fundraiser

Fanhua Zeng

Greenhorn
+ Follow
since Feb 26, 2008
Merit badge: grant badges
Biography
www.zengfanhua.com
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Fanhua Zeng

Jeff Verdegan wrote:

Fanhua Zeng wrote:However, in my case, I was trying to save a file, I have to specify the ‘Start in (optional)’ in the task scheduler so that the task scheduler knows where to store the file.



It's not the task scheduler. It's so that the JVM's "current directory" is the one you want it to be.

Alternatively, rather than specifying "start in", you could use a full path to the file, rather than a relative one. You could either hardcode that path (not generally a good idea) or provide it as an argument to the command you set up in Task Scheduler. I would prefer this over the "Start In" option because Java programs generally don't need to know or care what the JVM's current directory is.



I would say it depends on what problem you are deal with. In my case, my *.jar file has a separated configuration file (not in the jar). You probably would want to use “Start in (optional)”. The reason we have a separated configuration file is that non-java programmer people can just edit the file if something changes instead of coming to you and asking you to modify the java code.
12 years ago

ramya Lakshmanan wrote:I have a similar problem but in windows server 2003..
I would like to schedule a jar file to run which uses IO.
Can someone help?



Did you specify where your *.jar is?
12 years ago
When we call a .jar file using task scheduler, it runs fine if we don’t use file IO.
However, in my case, I was trying to save a file, I have to specify the ‘Start in (optional)’ in the task scheduler so that the task scheduler knows where to store the file.

The setting is:
Program/script: "C:\Program Files\Java\jre7\bin\javaw.exe"
Arguments: -jar C:\Users\admin\Desktop\TestTask.jar
Start in (optional): C:\Users\admin\Desktop ---- added

Cheers,
Fanhua
12 years ago
Hi.

I have an executable jar file and am trying to create a scheduled task using windows 7 Task Scheduler.
It runs fine as a .jar file when I double click it. But when I tell task scheduler to run it, it comes up with nothing.

Here is how I create tasks in the scheduler:

Program/script: "C:\Program Files\Java\jre7\bin\javaw.exe"
Arguments: -jar C:\Users\admin\Desktop\TestTask.jar

I have also tried using batch file but it doesn't work either, here is my script in bat file.

start "" "C:\Program Files\Java\jre7\bin\javaw.exe" -jar C:\Users\admin\Desktop\TestTask.jar

It also works fine when I double click the bat file.

How does task scheduler not run .jar files? Or I did something wrong?

My code:




Can someone please help?


Regards,
Fanhua





12 years ago
Where can I purchase cheaper SCJP voucher in New Zealand?
Can anyone please help?

Regards
Fanhua
16 years ago
How much is it as $$$$$ ?
16 years ago