0

I have 3 releases of Java 8 installed on Mac OSX. I need to switch temporarily to an older release, because a program I use has a problem with the newer release.

/Library/Java/JavaVirtualMachines >>> ls -al
total 0
drwxr-xr-x  5 root  wheel  160 Nov  1 11:12 .
drwxr-xr-x  4 root  wheel  128 Sep 21 00:02 ..
drwxr-xr-x  3 root  wheel   96 Jun 16  2017 jdk1.8.0_131.jdk
drwxr-xr-x  3 root  wheel   96 Oct 16  2017 jdk1.8.0_144.jdk
drwxr-xr-x  3 root  wheel   96 Oct 24 12:02 jdk1.8.0_181.jdk

/Library/Java/JavaVirtualMachines >>> which java
/usr/bin/java

/usr/bin >>> ls -al java
lrwxr-xr-x  1 root  wheel  74 Nov  1 11:03 java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

How do I make jdk1.8.0_144.jdk the current system version of java temporarily until I can get the program updated?

Thanks,

jblye
  • 363
  • 1
  • 7
  • By setting $PATH environment variable. export PATH=:$PATH – SaiNageswar S Nov 16 '18 at 15:15
  • Yes, one of the answers to that question contained a link that is what I was looking for: https://gist.github.com/hogmoru/8e02cf826c840914a8ed93fd418ed88e Basically, I just needed to go into this directory /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents Then I needed to: sudo mv Info.plist Info.plist.disabled – jblye Nov 16 '18 at 15:37

2 Answers2

2

Run this command to see Java versions that currently you have :

/usr/libexec/java_home -V

The output will be like this :

Matching Java Virtual Machines (2):
1.8, x86_64:   "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8/jdk/Contents/Home
1.6, x86_64:   "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.jdk/Contents/Home

Select your desired Java version as default by following export command : export JAVA_HOME ='/usr/libexec/java_home -v 1.6' in your shell’s init file.

I hope it helps you

Mohammadreza Khatami
  • 1,444
  • 2
  • 13
  • 27
0

Setting your JAVA_HOME environment variable to your desired JDK version should do the trick.

Add export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home to your .bash_profile

DaveyDaveDave
  • 9,821
  • 11
  • 64
  • 77
wiomoc
  • 1,069
  • 10
  • 17
  • As @sainageswar-s mentioned in the comments above, you may also have to pre-pend the `$JAVA_HOME` environment variable to `$PATH`. The problem is by default there's a symbolic link at `/usr/bin/java` that may get picked up. – Jason Armstrong Nov 16 '18 at 15:37