简体   繁体   中英

Ubuntu - Default Java, Oracle JDK not detected as installed

I have an ubuntu installation with Oracle JDK 1.8.0_141 was installed using the below guide.

https://www.digitalocean.com/community/tutorials/how-to-manually-install-oracle-java-on-a-debian-or-ubuntu-vps

tar 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 has been completed.

But when I try to install maven using apt-get it tries to install default-jre rather than using this installed version.

Any idea where can I change this default behavior.

Thanks

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 : https://www.wikihow.com/Install-Oracle-Java-JDK-on-Ubuntu-Linux

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM