Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting JAVA_HOME and JRE_HOME path

Tags:

java

I have been allocated a Linux box in which has java available

# java -version
java version "1.7.0_09-icedtea"
OpenJDK Runtime Environment (rhel-2.3.4.1.el6_3-x86_64)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)

# ls -l /usr/bin/java
lrwxrwxrwx. 1 root root 22 Feb  8  2013 /usr/bin/java -> /etc/alternatives/java

I am new to Java and not sure if JRE is installed in ths box but based upon search:

# rpm -q jre
package jre is not installed
# find / -iname java -print 2>/dev/null
/usr/lib/java
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre/bin/java
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/bin/java
/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre/bin/java
/usr/bin/java
/usr/share/java
/var/lib/alternatives/java
/etc/alternatives/java
/etc/java
/etc/pki/java

But

# echo $JAVA_HOME

# echo $JRE_HOME

So is JAVA is installed and JRE also - am I correct but what value I should set for JAVA_HOME and JRE_HOME env variables?

like image 262
Programmer Avatar asked Apr 30 '15 10:04

Programmer


2 Answers

I am not sure about any other version of Linux, but in Ubuntu you need open home/.bashrc and add in the end of file

export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64

export PATH=$JAVA_HOME/bin:$PATH

after that, save file and relogin.

EDIT

java will know where is jre by JAVA_HOME.

like image 77
Simpson Avatar answered Sep 18 '22 19:09

Simpson


firstly try to get out of root user if possible than after that change below in your ~/.bash_profile

JAVA_HOME=/usr/java/<Java version 7 jdk>; export JAVA_HOME // you can also try JAVA_HOME=/usr/java/jdk 7 version/bin/java
PATH=$JAVA_HOME/bin:$PATH; export PATH

save it and then

now source ~/.bashrc

after that try

echo $JAVA_HOME it will produce the expected result.

like image 31
Bhargav Modi Avatar answered Sep 20 '22 19:09

Bhargav Modi