10

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?

5 Answers 5

9

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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.

4 Comments

Are my settings now correct: $echo $JAVA_HOME /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/ $echo $JRE_HOME /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre/
no still its not correct change it to $JAVA_HOME /usr/java/jdk1.7.0.9.x86_64 than it should work properly
But : $ls -l /usr/java/jdk1.7.0.9.x86_64 ls: cannot access /usr/java/jdk1.7.0.9.x86_64: No such file or directory please confirm?
@Prakash ok than your previous setting seems correct and you are on right path i guess and JRE home path is not required but still you can do it
1

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

and JRE_HOME should be /jre

Comments

1

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

1 Comment

No trailing slash.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.