This discussion is archived
9 Replies Latest reply: Mar 29, 2007 8:16 AM by 807596 RSS

Cannot find javac compiler

807596 Newbie
Currently Being Moderated
I have recently installed apache tomcat and the J2SE SDk on my windows machine and have managed to get tomcat to run. However, when i try to test a jsp page I get an error saying ii cannot find the javac compiler. The error I amgetting is shown below.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP
     org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
     org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:346)
     org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:414)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
     org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

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
     org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:106)
     org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:935)
     org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764)
     org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
     org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

I have checked my environment variables that I set up and I cannot finad anything wrong with them as they all seem to point to the right directory. Here are my environment variables.

CLASSPATH = C:\jdk1.5.0_02\lib\tools.jar;C:\Servers\Tomcat 5.0\common\lib\servlet-api.jar;C:\Servers\Tomcat 5.0\common\lib\jsp-api.jar

JAVA_HOME = C:\jdk1.5.0_02

PATH = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\ATI-CPanel;C:\Program Files\Pragma\Clients;C:\Program Files\MySQL\MySQL Server 4.1\bin;C:\jdk1.5.0_02\bin

Does anyone have any idea what the problem could be? Any solutions would be much appreciated.

Thanks
  • 1. Re: Cannot find javac compiler
    796365 Newbie
    Currently Being Moderated
    The material you posted shows spaces before and after the equal sign for both the CLASSPATH and JAVA_HOME.

    By including a space before the equal sign, you're setting values for
    "CLASSPATH " and
    "JAVA_HOME "
    Java/Windows is looking for
    "CLASSPATH" and
    "JAVA_HOME"
    The space following the equal sign may be (or may not be) ok, depending on the way the program that's reading the line is coded. The standard is no space.
  • 2. Re: Cannot find javac compiler
    807596 Newbie
    Currently Being Moderated
    I have recently installed apache tomcat and the J2SE SDk on my windows machine and have managed to get tomcat to run.
    the error i have got is below:
    Exception:
    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
         at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:106)
         at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:935)
         at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764)
         at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:282)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:328)
         at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:427)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:142)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
         at java.lang.Thread.run(Thread.java:536)

    Does anyone have any idea what the problem could be? Any solutions would be much appreciated.

    Thanks
  • 3. Re: Cannot find javac compiler
    jwenting Journeyer
    Currently Being Moderated
    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


    Seems quite clear to me... Learn to read error messages...
  • 4. Re: Cannot find javac compiler
    807596 Newbie
    Currently Being Moderated
    Got this quick fix from another forum - copy the tools.jar file
    from: C:\j2sdk1.4.2_XX\lib
    to: C:\TomcatXXX\common\lib

    I was backing out a running java 5 and Tomcat 5.5 install to java 4 /Tomcat 5.0 when I got this same error...

    When testing the javac is visable to the OS from a cmd window... I have 2 other installs running without this fix and I can not see any difference.

    Any suggestions on other things to check beyond typeOOO's.
  • 5. Re: Cannot find javac compiler
    807596 Newbie
    Currently Being Moderated
    Thanks a lot
  • 6. Re: Cannot find javac compiler
    807596 Newbie
    Currently Being Moderated
    Thank you. MAX_HAL you just saved me hours of headache.
  • 7. Re: Cannot find javac compiler
    807596 Newbie
    Currently Being Moderated
    Thanks Max for the clue.
  • 8. Re: Cannot find javac compiler
    807596 Newbie
    Currently Being Moderated
    Thanks again. This answer saves yet another lost soul.
  • 9. Re: Cannot find javac compiler
    807596 Newbie
    Currently Being Moderated
    You saved my hours...thanks a lot!