Default Java not detected by Maven as installed

I have an Ubuntu installation with Oracle JDK 1.8.0_141 that was installed using this guide.

tar file was extracted to /opt/jdk and below commands used to set java as default.

update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_05/bin/java 100
update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_05/bin/javac 100

java -version command works fine after these have been completed, but when I try to install maven using apt-get it tries to install default-jre rather than using this installed version.

Do you have any idea how I can change this default behavior?

1

1 Answer

This was solved after setting the kava alternative

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk/jdk1.8.0_144/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/jdk/jdk1.8.0_144/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/jdk/jdk1.8.0_144/bin/javaws" 1

It still install the default jdk when installing maven. But uses oracle jdk when building.

Thanks for the wikihow page :

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like