Skip to main content

Java 7 on Mac OS X?

Posted by joconner on August 21, 2011 at 12:35 AM PDT

I recently installed Java 7 on my Mac OS X system. Although the installation went smoothly, I did run into one problem that might not be a big issue for you.

I didn't go through the hassle of compiling it for myself. Instead, I opted to grab a precompiled JDK from here: http://code.google.com/p/openjdk-osx-build/downloads/list?q=label:Featured

Specifically, I chose the OpenJDK 1.7 universal (32/64 bits) from Mac OS X branch download. Then I ran the /Applications/Utilities/Java Preferences.app to 1) pull both 1.7 versions to the top of the list, and 2) select those 1.7 versions, and 3) unselect the 1.6 JDK I also have installed.

NetBeans seems to run just fine. I'm able to create a new target JDK for the IDE, etc.

Now the problem: I tried running jrunscript from the command line to do some simple tests of new functionality in Java 7. I have found the simple jrunscript JavaScript interpreter to be an excellent way to quickly access Java classes for simple tests, confirmation of APIs, etc. Oddly, the tool didn't run correctly despite being available in the JDK's bin directory. Here's the output of my attempt:

$ which java
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/bin/java
$ which jrunscript
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/bin/jrunscript
$ jrunscript
script engine for language js can not be found

 Apparently, the JavaScript engine isn't also included in this download? Ever see this? Hava a solution?

Related Topics >>

Comments

sorry if this is a naive response, but it appears that the ...

sorry if this is a naive response, but it appears that the copy of rt.jar included in the download you chose (referring to OpenJDK-OSX-1.7-universal-20110818.dmg, specifically) is missing com.sun.script.javascript.RhinoScriptEngineFactory (per the META-INF/services/javax.script.ScriptEngineFactory entry, as follows, since the service provider mechanism is used to locate instances):

com.sun.script.javascript.RhinoScriptEngineFactory #javascript

In my Win x64 install of JDK 7, I find this file present in jre/lib/resources.jar/META-INF/services. I don't see this present in resources.jar in OpenJDK-OSX-1.7-universal-20110818.dmg, though.

Afraid I'm not sure what accounts for this in terms of the openjdk-osx-build package.

This exactly topic is discussed at the ...

This exactly topic is discussed at the MacOSX OpenJDK port alias:

http://mail.openjdk.java.net/pipermail/macosx-port-dev/2011-August/000767.html

In a few words: Rhino-based implementation of JavaScript is not a part of OpenJDK and therefore not inherited by MacOSX port.

Artem

 

 To add this anything that uses the classes such as ...

To add this anything that uses the classes such as com.sun.* may not be included in the OpenJDK and can only be found in the official distribution.

 Hi to all, I'm the guy behind OpenJDK OS/X Build ...

Hi to all,

I'm the guy behind OpenJDK OS/X Build project

The miss in Rhino and scripting has allready been discussed with some users in the past. I'll be happy to add jrunscript + rhino support but I need more information to add this in the OpenJDK current build.

Advices and contributions are more than welcomed.