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- So, I set it to JAVA_HOME, but I still cannot execute javac command. What am I doing wrong here?

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

1 Answer 1


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-
export PATH=$JAVA_HOME/bin:$PATH

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .