Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 1230  / 2 Years ago, sun, june 12, 2022, 8:45:16

By default my ubuntu system is installed with the following java version:



java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)


If I type which java it tells me /usr/bin/java.



Now, I have just installed Oracle's Java from their website and have unpacked it inside the directory: opt/local



How do I make the default Java start from opt/local so that I am using Oracle Java instead of OpenJDK? Is this something I need to auto-configure inside my bashrc?
`
Thanks, and if you need more information let me know!


More From » java

 Answers
1

Ubuntu's alternative command management will be helpful here I think.


It's basically organized this way



generic link(e.g. /usr/bin/java) -> buffer link(e.g. /etc/alternatives/java) -> actual command or executable (e.g. /opt/jdk/java)


So you can update the buffer link so that it points to your choice of actual command/executable and still use the generic link to get the job done everywhere as before
(of course assuming both commands provides proper functionality ;).


Here is a nice guide to update JVM of your choice through update-alternatives command. So do the following



sudo update-alternatives --install "/usr/bin/java" "java" "/opt/local/jdk-xx.xx/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/local/jdk-xx.xx/bin/javac" 1


You can go on and update the java browser plugin and web-start plugin too as mentioned in the guide. Then choose the java of your choice by



sudo update-alternatives --config java
sudo update-alternatives --config javac

[#30261] Monday, June 13, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ardingiba

Total Points: 497
Total Questions: 95
Total Answers: 109

Location: Gabon
Member since Sat, Jan 15, 2022
2 Years ago
;