Unable to find a javac compiler

From EggeWiki
Revision as of 19:58, 13 December 2009 by Brianegge (talk | contribs) (Created page with 'In Tomcat, Jetty, or another servlet container, you may receive an error stating the javac compiler can't be found. The obvious reason is if you are running from a JRE and not a…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In Tomcat, Jetty, or another servlet container, you may receive an error stating the javac compiler can't be found. The obvious reason is if you are running from a JRE and not a JDK, however, it can still happen even when running a JDK.

The following is a typical error message: <geshi> HTTP ERROR: 500

Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK. It is currently set to "/java/jdk1.6.0_17/jre"

RequestURI=/web/ Caused by:

Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK. It is currently set to "/app/java/jdk1.6.0_17/jre" at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:108) at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1058) at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:882) at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:472) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:439) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:363) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:757) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:416) at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:334) at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126) at org.mortbay.jetty.servlet.DefaultServlet.doGet(DefaultServlet.java:463) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) </geshi>

You can verify the running JVM properties using the jinfo command. Example:

<geshi> /java/jdk1.6.0_17/bin/jinfo -sysprops 26314 | grep java.home Attaching to process ID 26314, please wait... Debugger attached successfully. Server compiler detected. JVM version is 14.3-b01 java.home = /java/jdk1.6.0_17/jre </geshi>

The easiest solution is to copy the tools.jar into the lib directory.

<geshi> cp -p /java/jdk1.6.0_17/lib/tools.jar /java/jdk1.6.0_17/jre/lib/ </geshi>