I'm working on a Scala Project with Eclipse (Indigo SR2). Today I updated my machine to Mountain Lion because we need some functionality of JDK 7. Installing JDK 7 worked fine:
$ java -version
java version "1.7.0_13"
Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
In Eclipse I changed the following settings:
/Library/Java/JavaVirtualMachines/jdk1.7.0_13.jdk/Contents/Home
JDK1.7.0
Then I restarted Eclipse and tried to run a script. However, I always get the error:
value getPlatformMXBean is not a member of object java.lang.management.ManagementFactory
Said method is only available as of Java 1.7 and Eclipse does not seem to find it although command-clicking on it reveals the function in the class ManagementFactory
. About Eclipse => Configuration shows that it is still using JDK 6 (java.runtime.version=1.6.0_37-b06-434-11M3909
), but I need JDK 7.
So I tried the following (as also described on StackOverflow and other sites):
-vm /Library/Java/JavaVirtualMachines/jdk1.7.0_13.jdk/Contents/Home/bin/java
to the eclipse.ini file (double checked the path, the proper location in the file according to the eclipse website, and also added the newline in between)$ /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse -vm /Library/Java/JavaVirtualMachines/jdk1.7.0_13.jdk/Contents/Home/
But no luck, Eclipse keeps starting with only JDK-6. What is strange is that I can explicitly change the JRE in Run=>Run Configurations
to JDK7 and it will run it that way. But I would not want to change that for every single runnable file.
Any further suggestions?
Thanks to the hint from EECOLOR, I was able to use the Scala plugin in Eclipse Juno, where the JDK7 runs just fine. However, now I run into what appears to be a dependency issue. The exception I get can be seen here: https://gist.github.com/anonymous/ac0f3a3655419e5149fa
Strangly, the file just starts fine when I run it from the command line with a simple java -cp JARFILE com.AND-SO-ON.file
. For building the sources and getting the dependencies, we use SBT.
My Eclipse.ini looks as follows (default except for the Xmx):
-startup
../../../plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.200.v20120522-1813
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Dhelp.lucene.tokenizer=standard
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
-XX:MaxPermSize=256m
-Xms40m
-Xmx1060m
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
The same project (i.e. really the same project, not just the same code) runs without dependency problems in Eclipse Indigo. Edit: Just found out, that this exception is caused by JDK7 and not the Eclipse version used.
I am using the preview version that supports Juno just fine: http://scala-ide.org/download/milestone.html#scala_ide_21_milestone_3
In the meantime, I managed to solve these problems.
First try:
sbt eclipse
Oops, does not work! I still get this exception:
value getPlatformMXBean is not a member of object java.lang.management.ManagementFactory
... which is strange because Eclipse now really runs with the JDK7. Without digging any deeper, I just gave Eclipse Juno a shot.
Second Try:
Conclusion:
So I am not sure why, but Eclipse Indigo somehow does not like getPlatformMXBean
. It does not appear to be an issue with the JDK but Eclipse itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With