Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to install mutiple Java OS's on Mac?

 
Mike London
Ranch Hand
Posts: 1185
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every time Apple pushes a new Java installation, it wipes out everything on the Mac and replaces it with Apple's new version.

Therefore, I'm unable to, say, keep a Java 5 installation around.

Is my only recourse to develop on the Mac to recompile everything in Java 6?

I do not understand why Apple won't give us more control into what happens with Java installations.

Recompiling all my apps would be huge pain.

Thanks in advance for any replies.

-- Mike
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think anything is wiped out - merely updated. Check the /System/Library/Frameworks/JavaVM.framework/Versions directory; mine has functional versions of Java 1.4.2, Java 1.5.0 and Java 1.6.0 in it.
 
Mike London
Ranch Hand
Posts: 1185
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From my inspection, the Java 5 directory was wiped, but (the directory itself) left intact and turned into a link pointing to Java 6.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's just a symbolic link pointing to the most recent version.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a bummer. The ones on my machine are definitely different JVMs:

java version "1.4.2_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_22-b02-329)
Java HotSpot(TM) Client VM (build 1.4.2-92, mixed mode)

java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03-333-9M3125)
Java HotSpot(TM) Client VM (build 1.5.0_22-147, mixed mode, sharing)

java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04-248-9M3125)
Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01-101, mixed mode)
 
Mike London
Ranch Hand
Posts: 1185
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:That's just a symbolic link pointing to the most recent version.


True, but there's nothing left in the Java 5 directory.

 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11855
187
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hadn't realized, but I have the same situation where all the previous versions (except 1.3.1) are just links:

[Edit] This is different on my PowerPC Mac: there the old versions have been kept, even though the OS is up to date:
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11855
187
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike - what is you are trying to do?

If you are just developing and using code on your own machine then it shouldn't really matter: the code you compiled when JDK 5 was the default should run without needing to be recompiled.

If you are developing with the intent to deliver to a machine that is running an older JVM, then you could use the "-target <release>" option within javac to specify what JVM you need to support. This can also be specified in your ant build files and/or your maven pom files if needed.
 
Mike London
Ranch Hand
Posts: 1185
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew Monkhouse wrote:Mike - what is you are trying to do?

If you are just developing and using code on your own machine then it shouldn't really matter: the code you compiled when JDK 5 was the default should run without needing to be recompiled.

If you are developing with the intent to deliver to a machine that is running an older JVM, then you could use the "-target <release>" option within javac to specify what JVM you need to support. This can also be specified in your ant build files and/or your maven pom files if needed.


Interesting...

So in Eclipse, I'd just update the "generated class file compatibility" tab to use project-specific settings, right?

I had tried the Java compatibility setting, but that supposedly requires that JDK to be installed.

Look forward to your reply.

Thanks.

Mike
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"class file compatibility" sounds about right. From the command line (or using Ant) one would need to set both "-source" and "-target".

Of course, the code will fail on Java 5 JREs if it actually uses Java 6 methods or classes. This setting merely produces a class file that works with earlier JREs, it does not ensure that the code will actually run. So any Java 6-specific stuff needs to be wrapped in checks that ensure it's not executed on a Java 5 JRE.

That's the advantage of using an actual Java 5 JDK for compilation - it would produce errors for anything it doesn't recognize.
 
Mike London
Ranch Hand
Posts: 1185
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:"class file compatibility" sounds about right. From the command line (or using Ant) one would need to set both "-source" and "-target".

Of course, the code will fail on Java 5 JREs if it actually uses Java 6 methods or classes. This setting merely produces a class file that works with earlier JREs, it does not ensure that the code will actually run. So any Java 6-specific stuff needs to be wrapped in checks that ensure it's not executed on a Java 5 JRE.

That's the advantage of using an actual Java 5 JDK for compilation - it would produce errors for anything it doesn't recognize.


Right, but, unfortunately, the Apple JDK 6 installation prevents you from keeping Java 5 too.

OK, at least I have a workaround. More work for me to make sure there's no Java 6-specific logic.

Thanks!

- Mike
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic