Programmer
Programmer

Reputation: 8687

Setting JAVA_HOME and JRE_HOME path

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?

Upvotes: 10

Views: 62917

Answers (5)

Aakash
Aakash

Reputation: 2109

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

set $JRE_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre

Upvotes: 1

Bhargav Modi
Bhargav Modi

Reputation: 2655

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.

Upvotes: 3

Simpson
Simpson

Reputation: 193

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.

Upvotes: 9

Mohan Raj
Mohan Raj

Reputation: 1132

JAVA_HOME should be set as parent folder of the java installed path

and JRE_HOME should be /jre

Upvotes: 1

KernelKoder
KernelKoder

Reputation: 746

Based on the output you have posted, i can draw the following conclusions:

  1. Based on the fact that java -version works on your machine, you have the JRE installed.
  2. The 'echo' statements do not produce any output as you have not set the environment variables for them.

On a side note, if you are planning on doing Java Development, then you need the JDK installed. The JRE comes as a subset of the JDK once installed

Upvotes: 0

Related Questions