How to set Oracle's Java as the default Java in Ubuntu?
I put the line:
export JAVA_HOME=/usr/lib/jvm/java-7-oracle
in my ~/.bashrc
file.
/usr/lib/jvm/java7-oracle
should be a symbolic link pointing to /usr/lib/jvm/java-7-oracle-[version number here]
.
The reason it's a symbolic link is that in case there's a new version of the JVM, you don't need to update your .bashrc
file, it should automatically point to the new version.
If you want to set JAVA_HOME
environment variables globally and at system level means use should set in /etc/environment
file.
Ubuntu - Default Java, Oracle JDK not detected as installed
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
How to set Java environment path in Ubuntu
set environment variables as follows
Edit the system Path file /etc/profile
sudo gedit /etc/profile
Add following lines in end
JAVA_HOME=/usr/lib/jvm/jdk1.7.0
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Then Log out and Log in ubuntu for setting up the paths...
Replace openjdk with oracle-jdk on Ubuntu
You can completely remove the OpenJDK
and fresh Install Oracle Java JDK
by following these steps:
Remove
OpenJDK
completely by this command:sudo apt-get purge openjdk-\*
Download the
Oracle Java JDK
here.Note: download appropriate file, for example if your system is x64 Ubuntu (i.e, Debian) the download file is named like this:
jdk-8u51-linux-x64.tar.gz
To find which version is your OS, check here
Create a folder named
java
in/usr/local/
by this command:sudo mkdir -p /usr/local/java
Copy the Downloaded file in the directory
/usr/local/java
. To do this,cd
into directory where downloaded file is located and use this command for copying that file to/usr/local/java/
:sudo cp -r jdk-8u51-linux-x64.tar.gz /usr/local/java/
CD into
/usr/local/java/
directory and extract that copied file by using this command:sudo tar xvzf jdk-8u51-linux-x64.tar.gz
After extraction you must see a folder named
jdk1.8.0_51
.Update
PATH
file by opening/etc/profile
file by the commandsudo nano /etc/profile
and paste the following at the end of the file:JAVA_HOME=/usr/local/java/jdk1.8.0_51
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATHSave and exit.
Tell the system that the new Oracle Java version is available by the following commands:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_51/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_51/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_51/bin/javaws" 1Make Oracle Java JDK as default by this following commands:
sudo update-alternatives --set java /usr/local/java/jdk1.8.0_51/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_51/bin/javac
sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_51/bin/javawsReload sytem wide PATH /etc/profile by this command:
source /etc/profile
Reboot your system.
Check Java JDK version by
java -version
command . If installation is succesful, it will display like the following:java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-xxx)
Java HotSpot(TM) Server VM (build 25.51-xxx, mixed mode)
That's it!
Note: We Assumed that the downloaded file is named jdk-8u51-linux-x64.tar.gz
and used this name in all the commands used in steps 2, 4 and 5. It may depends on the type of O.S, processor type (i.e., 32bit or 64bit)
Where is Java path set by default?
Finally this is what worked for me, Thank you all for coming out so quickly for help. Unfortunately I can not verify the solution as I have already got it set , and even if I delete my setting and try solution mentioned above , because in the process I have changed many environment variables I can never be sure if this is what actually solved it ..
Sorry about that
http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
How to install the JDK on Ubuntu Linux
Referring to Ask Ubuntu question How to set JAVA_HOME for OpenJDK?,
How to install Open JDK
(Java developement kit) in Ubuntu (Linux)?
Open Terminal from Application Dash or press Ctrl+Alt+T
Update repository:
sudo add-apt-repository ppa:openjdk-r/ppa # only Ubuntu 17.4 and earlier
sudo apt updateOptional: To search available distributions of
openjdk
, use the following command:apt search openjdk
Install the appropriate version with the following command:
sudo apt install openjdk-8-jdk
sudo apt install openjdk-8-source #this is optional, the jdk source codeFor
JAVA_HOME
(Environment Variable) type command as shown below, in "Terminal" using your installation path...export JAVA_HOME=/usr/lib/jvm/java-8-openjdk
(Note:
/usr/lib/jvm/java-8-openjdk
is symbolically used here just for demostration. You should use your path as per your installation.)For
PATH
(Environment Variable) type command as shown below, inTerminal
:export PATH=$PATH:$JAVA_HOME/bin
To check your installation:
java -version
Related Topics
"Comparison Method Violates Its General Contract!" - Timsort and Gridlayout
Exception in Initializer Error in Java When Using Netbeans
How to Bundle Images in Jar File
Httpservletrequest - Setcharacterencoding Seems to Do Nothing
Scanning Classpath/Modulepath in Runtime in Java 9
Hibernate:How Override an Attribute from Mapped Super Class
Java Jtree Directory Structure from File Paths
Termination of Program on Main Thread Exit
How to Change My Windows Desktop Wallpaper Programmatically in Java/Groovy
How to Execute Windows Commands Using Java - Change Network Settings
Performance Difference Between a Wild Card Import and the Required Class Import
Encrypt and Decrypt with Aes and Base64 Encoding
Is Gnu's Java Compiler (Gcj) Dead
Printing in Java to Label Printer
How to Quit a Java App from Within the Program