mismatch between java and javac version in MAC

21 views Asked by At

Initially, I had java 21 installed in my MAC. But I need to run an application which requires Java 8. So, I installed Java8 and exported the path in .bash_profile as well. But from the terminal when I try to see both javac and java version, I see a mismatch.

The content of the .bash_profile is given below.

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

I executed javac -version and java -version from terminal. They are giving different result. How can I fix it?

subhadip@Subhadips-MacBook-Pro ~ % javac -version
javac 21.0.1
subhadip@Subhadips-MacBook-Pro ~ % java -version
java version "1.8.0_391"
Java(TM) SE Runtime Environment (build 1.8.0_391-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.391-b13, mixed mode)
0

There are 0 answers