Maven3, Javac & Co. On Debian


Maven3 &the right JDK

I was trying to build Maven3, to build other stuff (hippo cms) and suddenly my system said:

/usr/src/apache-maven-3.0.5/build.xml:223: Unable to find a javac compiler; is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-6-openjdk-amd64/jre"

This means that I’m trying to compile Maven3 without having installed the JAVA SE jdk from Oracle website, but luky you, you can follow this link: [Download Java].

One negative thing is that you have to accept the software license and then you can just download the package within the same browser session, thus you have to SCP the tar.gz archive to your server machine. This is not lazy-sysadmin-friendly indeed. 😛

By the way what i’ve done in order to undertsand where and how this package should have been moved to work fine was to look around for already present java version on my system.
the command:

# which java

gives some info, mine gives:


Then with

# ls -al /usr/bin/java 
lrwxrwxrwx 1 root root 22 Apr 27 10:10 /usr/bin/java -> /etc/alternatives/java

We see a link pointing in /etc/alternatives. Let’s have a look there:

# ls -al /etc/alternatives/java
lrwxrwxrwx 1 root root 46 Apr 27 10:10 /etc/alternatives/java -> /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java

Another link to /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java, and that is the place where to extract our downloaded archive, so

# mv /usr/src/jdk1.7.0_21 /usr/lib/jvm/
# cd /usr/lib/jvm/
# ls -al
total 32
drwxr-xr-x  5 root root  4096 May  4 08:44 .
drwxr-xr-x 46 root root 12288 Apr 27 14:24 ..
lrwxrwxrwx  1 root root    20 Mar  5 10:16 java-1.6.0-openjdk-amd64 -> java-6-openjdk-amd64
-rw-r--r--  1 root root  2387 Mar  5 10:16 .java-1.6.0-openjdk-amd64.jinfo
drwxr-xr-x  5 root root  4096 Apr 27 10:05 java-6-openjdk-amd64
drwxr-xr-x  3 root root  4096 Apr 27 10:05 java-6-openjdk-common
drwxr-xr-x  8 uucp  143  4096 Apr  4 11:32 jdk1.7.0_21

Here we are!. You can see in red (last line of previous code snippet) our jdk dir. The one in blue is the one in use (I don’t know why it is linking somenthing in the same directory…) So,

# cd /etc/alternatives
# ls -al java
lrwxrwxrwx 1 root root 46 Apr 27 10:10 java -> /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java
# rm java
ln -s /usr/lib/jvm/jdk1.7.0_21/jre/bin/java java

Then finally, I could go back into the maven3 source directory and build it with ant… After tons of output and after having downloaded the internet, it builds.


Total time: 6 minutes 8 seconds

(Visited 1,207 times, 1 visits today)