Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] com.sun.tools.javac.Main is not on the classpath on Ubuntu Natty

Hi Chris,

have you already tried setting your default Java via

 sudo update-alternatives --config java

Don't really know, but maybe setting the default to JDK here solves your problem.

Regards
Andreas

On Wed, Oct 26, 2011 at 9:23 PM, Christopher Bare <christopherbare@xxxxxxxxx> wrote:
Hi,

I installed jetty 6.1.24-6 on Ubuntu Natty 11.04 via apt-get install
jetty. I also installed openjdk-6-jdk 6b22-1.10.2-0ubuntu1~11.04.1
OpenJDK Development Kit (JDK). <<<--- Note that this is the JDK not
just the JRE. I started Jetty using start.jar and when Jetty went to
compile a .JSP page, I got an error as follows:

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 "/usr/lib/jvm/java-6-sun-1.6.0.26/jre"
       at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:127)
       at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1088)
       at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:906)
       at org.apache.jasper.compiler.AntCompiler.generateClass(AntCompiler.java:226)
       at org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
       at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
       at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
       at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
       at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
       at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
       at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)

The Ant task Javac is looking to call classes that live in tools.jar,
and can't find them. Tools.jar is in
/usr/lib/jvm/java-6-sun-1.6.0.26/lib/.

I tried a few things, and still got the same error.

1) Setting JAVA_HOME to /usr/lib/jvm/java-6-sun-1.6.0.26 in the
environment or even in /etc/profile doesn't seem to help.

2) java -classpath blah/blah -jar start.jar is no good 'cause java
ignores classpath arguments when using -jar

3) # tried w/ both open-jdk and sun jdk.
   sudo -u jetty bash
   export CLASSPATH=/usr/lib/jvm/java-6-sun/lib/tools.jar
   export JAVA_HOME=/usr/lib/jvm/java-6-sun/
   java -jar start.jar

The kludge that finally worked was to symlink tools.jar into
/usr/lib/jvm/java-6-sun-1.6.0.26/jre/. (Ugly, I know!)

I'm guessing that one or more of Jetty, Jasper and the Ant Javac task
starts subprocesses or does classloader tricks, so that setting the
classpath for the ant.taskdefs.Javac must be done by configuration
somewhere. I'm also guessing it's trying to be smart and determine the
classpath automatically from the location of the java executable.
There's a symlink pointing /usr/lib/jvm/java-6-sun/bin/java ->
/usr/lib/jvm/java-6-sun/jre/bin/java. This is true of both java-6-sun
and java-6-openjdk. So, I'm pretty sure the choice of directory
structure and symlinking is fouling up Ant's or Jetty's automagic
classpath wizardry. I'm I right?

I'm pretty sure it's not good that installing Jetty and a JDK via
apt-get leads to this error. Should this be considered a bug in the
apt-get packaging? In Jetty? In Ant? In my brain? Or somewhere else?

And finally, is there a simple bit of configuration that could solve
this whole dilema?

Thanks for sticking with a long-winded post and for any clues!

- Chris
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top