go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  Set the JAVA_HOME Environment Variable
 
Subject: Set the JAVA_HOME Environment Variable
Author: Linux
In response to: Manage Different Versions of Java
Posted on: 10/20/2017 12:55:07 AM

Many java applications need to know where to load the JDK based on environment parameter JAVA_HOME

We can set it inside file /etc/environment:

$ sudo nano /etc/environment


Add at the end of file with this line:
JAVA_HOME="/usr/local/java/jdk1.8.0_152"


Save and exit the file, and reload it (or logout and login):
$ source /etc/environment


You can now verify it:
$ echo &JAVA_HOME
/usr/local/java/jdk1.8.0_152


 

> On 10/20/2017 12:44:41 AM Linux wrote:


Now the Ubuntu box has at least two versions of Java: the default openJDK & Oracle JDK. Here is how to manage what is to be used.

$ sudo update-alternatives --config java

There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      auto mode
  1            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode
  2            /usr/local/java/jdk1.8.0_152/bin/java            100       manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/local/java/jdk1.8.0_152/bin/java to provide /usr/bin/java (java) in manual mode


Here we chose Oracle JDK1.8 and linked it to /usr/bin/java




References:

 


 
Powered by ForumEasy © 2002-2022, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.