2

I have CentOS 6.7. I have installed Java 1.8. When I do Java -version I see the following output.

java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode) 

I need javac so I came to know that this is available only if I install JDK. So I installed JDK by executing the following command

yum install java-1.7.0-openjdk-devel 

The installation was successful. But now when I again execute the command java -version, I see the old result. If I try to execute javac at the command prompt I see the error '-bash: javac: command not found'. I observed that OpenJDK was installed to the directory /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.131.x86_64/bin. So, I set it to JAVA_HOME, but I still cannot execute javac command. What am I doing wrong here?

2
  • Although setting JAVA_HOME is necessary for running Java, executables are still searched in $PATH, not in $JAVA_HOME/bin.CommentedApr 4, 2017 at 10:36
  • I set the directory in the PATH variable, but I am getting the same error.
    – KurioZ7
    CommentedApr 4, 2017 at 10:40

1 Answer 1

3

I have fixed this issue by executing the following command. I was not setting the PATH variable properly. I executed the following two commands and my problem was fixed.

export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.131.x86_64 export PATH=$JAVA_HOME/bin:$PATH 
1

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.