Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Java 7 and Java 8 co-exist on OSX

Tags:

java

macos

java-8

I've installed Java 8 for development purposes but now I'd like to use Java 7 again.

How do I do this?

It seems to be insanely difficult.

Many thanks in advance. (I've tried using guigarage and that doesn't work)

like image 845
Dan Avatar asked Sep 10 '25 08:09

Dan


1 Answers

From a terminal: export JAVA_HOME=`/usr/libexec/java_home -v 1.x`, where x is the Java version.

I personally have a shell function that does that for me:

use-java () {
    export JAVA_HOME=`/usr/libexec/java_home -v 1.$1`
}

I just have to call use-java 7 or use-java 8 in order to change my current shell's Java version.

like image 72
Samy Dindane Avatar answered Sep 12 '25 21:09

Samy Dindane