Maven / jetty. Can't find JDK.

Hello,

I’m trying to run my maven project with mvn jetty:run which is giving me

Unable to locate the Javac Compiler in:
  /usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre/../lib/tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

So apparently the jdk jre cannot be found? I do have java-1_6_0-openjdk installed, and if it’s anything like windows I suspect I need to set JAVA_HOME to /usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre/bin/java
But how do I do this? Or if this isn’t the solution, what is? :wink:

  1. you could check where it realy is by using YaST > Software > Software Management, then search for the (installed) package and use the “Filelist” tab lower-right (scroll to the bold part, that is where the executables are).

  2. one sets an variable with

JAVA_HOME=/usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre/bin/java

one exports this to the environment of the current process (thus that it will be also available in chikd processes like the statements you type later in the same shell session) with

export JAVA_HOME

And this can be done in one statement

export JAVA_HOME=/usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre/bin/java

When you need this often in shell sessions, you could considder adding this statement to your* .profile*

Thanks Henk,

Last one is almost correct, the /bin/java part has to be ommited. So,

export JAVA_HOME=/usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre

Another step closer to getting this to work… on to the next challenge.

Just for the folks trying to do the same thing, openjdk apparently can’t do what needs to be done.
I ended up installing the sun jdk and using

export JAVA_HOME=/usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre

. Which still didn’t cut it for mvn:jetty run. However! This does work fine:

mvn org.mortbay.jetty:maven-jetty-plugin:run

Axeia wrote:

> --------------------
> export JAVA_HOME=/usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre
> --------------------
>
As far as I remeber this should be


export JAVA_HOME=/usr/lib64/jvm/java-1.6.0-sun-1.6.0

Similar for openjdk (the jre does not belong to the java_home).


openSUSE 11.3 64 bit | Intel Core2 Quad Q8300@2.50GHz | KDE 4.5 | GeForce
9600 GT | 4GB Ram
openSUSE 11.3 64 bit | Intel Core2 Duo T9300@2.50GHz | KDE 4.5 | Quadro FX
3600M | 4GB Ram

The idea was that with my point 1) you should find out what the real path is and in 2) I used just a path (I think the one you guessed) as an example to show how environment variables work.
But I think you got the idea.

For maven at the very least it seems to be needed, basically I got an error about it not being able to find it in some /bin/bin path, so I cut the path off short - just before the /bin.
So

export JAVA_HOME=/usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre

works.

Basically got everything working as I wanted to now, all of this was to use Hudson to able be to remotely checkout an application from svn and build it.

Axeia wrote:

>
> Basically got everything working as I wanted to now, all of this was to
> use ’ Hudson’ (http://hudson-ci.org/) to able be to remotely checkout an
> application from svn and build it.
>
Since it works for you this is ok.
I just want to point at the fact that the JAVA_HOME variable never includes
a part in its path that points to the jre within the jdk but to the root of
the jdk. Of course this also makes sense since the javac and the other
development tools are in

/usr/lib64/jvm/java-1.6.0-sun-1.6.0/bin/

and not in something like

/usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/bin/

so I wonder a bit how with that setting for JAVA_HOME your system is able to
find the javac compiler.


openSUSE 11.3 64 bit | Intel Core2 Quad Q8300@2.50GHz | KDE 4.5 | GeForce
9600 GT | 4GB Ram
openSUSE 11.3 64 bit | Intel Core2 Duo T9300@2.50GHz | KDE 4.5 | Quadro FX
3600M | 4GB Ram