java 7 does not work with eclipse 3.6 or open office

In preparation for downloading Eclipse 4.2 (Juno), I downloaded Java 7 for the Mac.  It was quite an experience.

TL/DR: Don’t use Java 7 with Eclipse 3.6 or Open Office 3.  Alternatives below.

Installed Java 7 for the Mac

Up to now, I’ve been doing all my Java 7 learning/testing/etc in a Linux JVM.  Now that Juno is out, it seemed high time to add it to my path.

  1. Download the dmg from jdk7.java.net or Oracle’s main site. (both are now Oracle versions.  The former is a slightly later version since it is a release preview.  Oddly enough installing the Oracle one uninstalled the newer preview version of the jdk7 one.
  2. Click on dmg.  Double click to get Java wizard
  3. Open finder.  In the go menu choose utilities
  4. Choose java preferences and uncheck Java 1.6 or previous versions of 1.7 you have downloaded.
  5. Now “java -version” at the command line is Java 7.

Dr Dobbs describes this well with screenshots although they do assume you know how to open the java preferences.

Eclipse problem

Error: “failed to create the Java virtual machine”

However, when I tried to launch Eclipse 3.6, I got “failed to create the Java virtual machine.”

The first thing I did was check my path still contained the JDK:

javac -version
javac 1.7.0_05

I then tried the Eclipse alias that runs at a command line which got more of an error message:

/Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse ; exit;
JavaVM: requested Java version ((null)) not available. Using Java at "" instead.
JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib
JavaVM FATAL: Failed to load the jvm library.
logout

This problem is discussed in a stackoverflow thread. Juno does fix this problem.

Summary: Stay on Java 6 with Eclipse 3.7 (Indigo) and go to Java 7 with Eclipse 4.2 (Juno).

 Open Office problem
Error: OpenOffice.org requires a Java runtime environment (JRE) to perform this task. The selected JRE is defective. Please select another version or install a new JRE and select it under Tools – Options – OpenOffice.org – Java.
Oh fun.  OpenOffice doesn’t yet play well with Java 7.  I wound up switching my system JRE back to 6 and my default Eclipse JRE to Java 7.  This makes everyone happy.