MacOS – Problem with installing Java: java: command not found

javamacmacos

I just installed Java 8.25 but I'm still not getting 'legacy' applications to work. I tried verifying the version in terminal:

manfred$ java --version
-bash: java: command not found

I think there's a conflict between two versions or something perhaps. How can I solve this?

Best Answer

Looks like Java is not in the path. I do something like this in my ~/.bash_profile

# Get Java Home for the specific version
JAVA_HOME=`/usr/libexec/java_home -v1.8 2>/dev/null`
# Add Java to the path
export PATH=$JAVA_HOME/bin:$PATH

Quit terminal once you create or edit ~/.bash_profile. FYI if you are creating ~/.bash_profile make sure you give it executable privileges.