go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  Set environment variable JAVA_HOME under Linux
 
Subject: Set environment variable JAVA_HOME under Linux
Author: Linux
In response to: Install JAVA JDK on AWS EC2 instance
Posted on: 10/12/2011 08:54:23 PM

There are three ways.

1). Set for current environment

$ export JAVA_HOME=/usr/java/jdk1.6.0_29


Type the following to verify
$ echo $JAVA_HOME
/usr/java/jdk1.6.0_29


2). Set for single user
Login to your account and open .bash_profile or .bashrc file
$ vi ~/.bash_profile

Type the following:
export JAVA_HOME=/usr/java/jdk1.6.0_29

Save and close the file. Just logout and login back to see the change.
$ echo $JAVA_HOME
/usr/java/jdk1.6.0_29


3). Set for all users
Login as root user and setup the global config in /etc/profile OR /etc/bash.bashrc file for all users:
# vi /etc/profile

Type the following:
export JAVA_HOME=/usr/java/jdk1.6.0_29


Save and close the file.

 

> On 10/12/2011 07:58:43 PM Linux wrote:

Download a JDK RPM from http://download.java.net/jdk6/. Look for "RPM" under "Linux". Copy the link address to "jdk-6u29-ea-bin-b08-linux-i586-23_sep_2011-rpm.bin" and then use curl.

# mkdir /usr/local/java
# cd /usr/local/java
# curl http://download.java.net/jdk6/6u29/promoted/b08/binaries/
jdk-6u29-ea-bin-b08-linux-i586-23_sep_2011-rpm.bin > jdk-rpm.bin


Then follow the instructions on http://alwajdi.blogspot.com/2007/12/how-to-install-snns-jdk-in-fedora-8.html to install the downloaded JDK.
# chmod 755 jdk-rpm.bin
# ./jdk-rpm.bin 
# /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_29/bin/java 100
# /usr/sbin/alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_29/bin/jar 100
# /usr/sbin/alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_29/bin/javac 100
# /usr/sbin/alternatives --config java


Type the following command to verify the exact path to which java executable under UNIX / Linux:
# which java
/usr/bin/java

Also to make sure the version is correct:
# java -version
java version "1.6.0_29-ea"
Java(TM) SE Runtime Environment (build 1.6.0_29-ea-b08)
Java HotSpot(TM) Client VM (build 20.4-b01, mixed mode, sharing)





References:

 


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