views:

85

answers:

4

I have a Java application hosted on a remote tomcat instance that executes a bat file which contains the following line

javac filename.java

I receive the following error :-

'javac' is not recognized as an internal or external command, operable program or batch file.

I have set the path in the environmental variables. I tried running the same bat file on the machine, it works(which means there is nothing wrong with the path). But running it through the application gives the error. What might be the problem?

+2  A: 

Setting the correct path in your environment does not fix the path in the environment of the running tomcat process. If you changed the path in the system settings, a tomcat restart (or system reboot) probably solves your problem.

rsp
Thanks man!! job done
Ajay
A: 

Once you add %JAVA_HOME%\bin to the PATH var on the remote machine (assuming you have %JAVA_HOME% set there), you will need to run up a new cmd window for the new PATH to be available.

akf
A: 

You should set the classpath for the user who is executing tomcat, not only for your login user.

Eucuepo
This is not a classpath problem at all.
Stephen C
A: 

If you have the JRE installed, and not the JDK, you'd be able to run Tomcat but there wouldn't be a javac.exe. Go to JAVA_HOME/bin and see if there's a javac.exe. If not, you have the JRE installed, and you'll have to go get the JDK.

Just curious - why is your Tomcat app calling javac.exe? Are you creating classes on the fly? If yes, why would you not be generating byte code using ASM instead?

duffymo