0

I currently have Java 6 installed on my system (please don't laugh) and we are moving to Java 8. So we have changed the main branch of our application to use Java 8, however, we need to support old versions that run on Java 6. So we need to easily alternate.

I understand that java (command) points to /usr/bin/java, which is a symlink to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java. That directory looks as follows:

/System/Library/Frameworks/JavaVM.framework/Versions@16:44:32>ls -la
total 64
drwxr-xr-x  11 root  wheel  374 Jun 16 16:39 .
drwxr-xr-x  12 root  wheel  408 Jun 16 16:43 ..
lrwxr-xr-x   1 root  wheel   10 Jun 16 16:39 1.4 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 Jun 16 16:39 1.4.2 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 Jun 16 16:39 1.5 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 Jun 16 16:39 1.5.0 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 Jun 16 16:39 1.6 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 Jun 16 16:39 1.6.0 -> CurrentJDK
drwxr-xr-x   8 root  wheel  272 Jun 16 16:43 A
lrwxr-xr-x   1 root  wheel    1 Jun 16 16:39 Current -> A
lrwxr-xr-x   1 root  wheel   59 Jun 16 16:39 CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents

I can install Java 8 without uninstalling Java 6 and would like to have a mechanism of easily repointing the related commands in /usr/bin from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents to /System/Library/Java/JavaVirtualMachines/1.8.0.jdk/Contents.

Is there a quick and existing way of doing it as opposed to writing my own script when I have to go to legacy branches/versions of our app for troubleshooting and PROD support? Like flip the java alternative from 6 to 8 and it does it all for you.

  • Don't laugh at Java 6! It's the only Java my Snow Leopard server can run. ;) – sudo Jun 26 '14 at 21:21
  • 1) Did you try changing versions from the command line: java -version:< version number >. 2) Is it possible for your purposes to use java from the command line, you could set the old JVM with PATH. – Brian Duke Jun 27 '14 at 0:08

You must log in to answer this question.

Browse other questions tagged .