1

I created a ".bat" file and scheduled to run every 15 mins in windows 2008 server. In the ".bat" file i gave the following. When I try to run the bat file in command line, it works fine. IF i schedule it, it throws "could not find or load main class". Contents of the bat file are given below.Let me know if I am missing anything.

@echo off
javac -cp C:\foo\abc.jar;C:\foo\xyz.jar; sample.java
java -cp C:\foo\abc.jar;C:\foo\xyz.jar;. sample
pause
Leo
  • 189
  • 6
  • 21
  • 2
    I'm guessing the working directory of the `bat` file is not what you expect. `javac` fails silently since `sample.java` is not found, and `java` then fails noisily because the class is not there? Try deleting `sample.class` and running the `.bat` file from the scheduler to see if it gets compiled correctly. – millimoose Sep 12 '13 at 00:33

1 Answers1

0

There are few things to consider / debug:

  1. What is the current directory when running windows task scheduler?
  2. What is the user used to run the task scheduler?
  3. Does the user has sufficient permission to run the command (especially if it involves file IO) ?
  4. What is the environment variables setup on the user? Does the user has all java paths on the env vars?
gerrytan
  • 40,313
  • 9
  • 84
  • 99