I have a DOS batch file to run on a daily basis.
Something similar like –
@ECHO ON
SET COMMON_LIB=commons-io-1.3.1.jar;
SET AR_CLASS_PATH=%CLASSPATH%%COMMON_LIB%
java -cp %AR_CLASS_PATH% -Xms128m -Xmx256m FileCreating
PAUSE
When I run the batch file directly, i.e. double cliking on the .bat file, it runs fine, the command window opens up and executes all the required commands( note the PAUSE ).
But when I schedule a daily task, I see the status as Running. Also, when I right click on the task, it gives me an option to end the task(when status is Running ) but I cant see the command window and so I cant make out if it has been processed or the error it has generated.
And so, cant understand if the error is in classpath or my java code or somewhere else.
The environment is Windows Server 2003 R2 EE, SP2. The user has Admin priviledges.
I checked but there is no file of Schedlgu.txt in WINDOWS\Tasks dir.
One thing I noticed was the CLASSPATH value had no reference to the jdk/bin, can that be a issue?
Please advise.
EDIT
Just to simplify things, I commented the java command for the bat file to do almost nothing then set some variables and then pause to keep the window open. Still no success.
Well, after some trial and error, I was finally able to get my scheduled task to run.
As suggested by Dave, I had the std out redirected to a text file, so that I can see what errors are generated. But the text file came out blank and the task was run.
So I added a
java -versionand still no result, even now the text file was blank.
Then, I created a simple
HelloWorldprogram and added this java command to the bat fileThe CheckHW.txt had the output text, I had given in the
HelloWorldprogram.So now all these added to the confusion and annoyance.
Interestingly and surprisingly, the issue was the
CLASSPATHvariable I am using to set the classpath with thejavacommand.I dont know how and importantly why it started working after I removed the
%CLASSPATH%fromThe bat file in my question was and is working on a Windows XP system without this change.
I wonder some setting on the Windows 2003 Server related to Java class path was not allowing it to process.