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?

KurioZ7
  • 503
  • 6
  • 10
  • 19

1 Answers1

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
Romeo Ninov
  • 16,541
  • 5
  • 32
  • 44
KurioZ7
  • 503
  • 6
  • 10
  • 19
  • Another approach is to use the alternatives system, per https://unix.stackexchange.com/a/598398/5132 , which wlll yield a symbolic link at `/usr/bin/javac`, with `/usr/bin` almost certainly already being on your path. See also https://unix.stackexchange.com/a/123424/5132 . – JdeBP Aug 07 '20 at 18:05