Tuesday, March 1, 2011

'javac' cannot be found problem

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?

From stackoverflow
  • 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.

    Ajay : Thanks man!! job done
  • 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.

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

    Stephen C : This is not a classpath problem at all.
  • 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?

0 comments:

Post a Comment