0

When I try to install Java on my Linux machine I am getting message already installed but I still cannot retrieve java -version. Please help.

[root@localhost Downloads]# rpm -ivh jre-8u31-linux-i586.rpm 
Preparing...                   ###########################################
[100%]  package jre1.8.0_31-1.8.0_31-fcs.i586 is already installed
[root@localhost Downloads]# whereis java
java: /etc/java /usr/lib/java    /usr/share/java 
[root@localhost Downloads]# java-version
bash:    java-version: command not found 
[root@localhost Downloads]# java -version
bash: java: command not found

Thanks in advance!
Kumar

user1766169
  • 1,932
  • 3
  • 22
  • 44
  • 1
    Try `/usr/lib/java -version` - or put the path path to the java executable to your `PATH` variable and run `java -version` again – Trinimon Feb 03 '15 at 07:33
  • see https://ask.fedoraproject.org/en/question/49060/how-to-make-oracle-jdk-and-jre-as-default-java-in-fedora-20/ – Farvardin Feb 03 '15 at 07:38

1 Answers1

0

You need to set environment variables JAVA_HOME and PATH. You can do this by executing:

export JAVA_HOME=/usr/java/jdk1.5.0_07

export PATH=$PATH:/usr/java/jdk1.5.0_07/bin

You should replace /usr/java/jdk1.5.0_07 with you java installation path.

For more details check the link below: http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/

Andrey E
  • 856
  • 8
  • 18