Java is open-source, fortunately. Accessing its source code is, unfortunately, not so intuitive on Mac OS X Lion when using Eclipse. This article will guide you through the steps required to be able to view Java’s source code in Eclipse.
- 2Downloading the JDK
- 3Using the JDK in Eclipse
Determine your Java version ∞
Apple uses a different versioning system for Java than Oracle. For example, on my system the actual Java version is “1.6.0_29” (determined by calling
java -version
from a terminal), but this version comes as “Java for Mac OS X 10.7 Update 1” through Apple’s Software Update. Java software for your computer, or the Java Runtime Environment, is also referred to as the Java Runtime, Runtime Environment, Runtime, JRE, Java Virtual Machine, Virtual Machine, Java VM, JVM, VM, Java plug-in, Java plugin, Java add-on or Java download.
To find out which Java Update you’re running, go to the
System Preferences
and click Software Update
. Then you click on
Installed Software
and search the list for the latest Java update (here “Update 1”). That’s the “Java version” you need to know.
Downloading the JDK ∞
When working with Java, you need to distinguish two Java software package types:
- JRE: The “Java Runtime Environment” is necessary to run Java application. You cannot, however, compile Java programs with just the JRE.
- JDK: The “Java Development Kit” is required when you want to compile Java programs. The JDK includes the JRE, and also comes with Java’s source code.
Remark: Eclipse comes with its own Java compiler. That’s why you don’t need to install a JDK to create Java programs with Eclipse. Eclipse doesn’t ship with the Java source code though. That’s why we still need the JDK.
The JDK for Mac OS X comes as “Java Developer Package”. You can download it here:
You’ll need an AppleID to download the JDK. Fortunately, it’s free but you still need to register it. (Tip: You can use the same you use in the iTunes Store.) After logging in, type “java developer package” in the search field (see screenshot).
Make sure the you download the Java Developer Package matching your Java version. In my case, this is “Mac OS X 10.7 Update 1”.
Note: Don’t confuse “10.7” for Java 7. It’s still Java 6. (So don’t download a “10.6” version when you’re running Mac OS X Lion.)
Then install the JDK. This will install the JDK under:
Note: There’s also the directory
/System/Library/Frameworks/JavaVM.framework/
. However, this directory seems to be deprecated. The Java source code will be located here:
Check an already installed JDK ∞
To check whether you’ve already installed a JDK, check the list of installed updates (see above) for an entry called “Java Developer Package”.
Note: Unfortunately, the Java Developer Package listed in the list doesn’t have any (visible) version information attached to it. I’m not sure whether the JDK will be updated automatically when a new version becomes available.
To check the actual Java version of the installed JDK, go to
/Library/Java/JavaVirtualMachines/
and check whether a package called like “1.6.0_29-b11-402.jdk” can be found there. In this example, the Java version would be “1.6.0_29”. Using the JDK in Eclipse ∞
On Mac OS X, Eclipse provides an automatic way to determine the directory of the installed JDK. Go to the Eclipse Settings and open
Java
–>Installed JREs
. Then, by clicking on the
Search...
button, would find the newly installed JDK. Unfortunately, there seems to be a bug in Eclipse Ingido (3.7 – and probably in earlier versions, too) that prevents this button from working correctly. Clicking on it doesn’t do anything when there’s already one (and only one) JRE listed here; see screenshot. To fix this problem, do the following:
- Duplicate the existing entry (by hitting the
Duplicate...
button) - Delete the original entry; it’s the one with checked checkbox in front of it.
- Then click
Search...
. This should add two new entries to the list (see next screenshot). - Delete the entry you’ve created in step 1 (i.e. the duplicate of the original entry).
- Check one of the remaining entries. Note: The new two entries are linked. If you check one, both will be checked. Also, you can’t delete the entry for
/System/Library/Java/...
. Trying to do so will delete the other entry. - Close the Settings dialog with OK.
- Restart Eclipse. This will remove the wrong entry (the one for
/System/Library/Java/...
) from the list.
The list of installed JREs then should look like this:
Manually adding a JDK ∞
If you want (for any reason) to add the JDK manually, here’s how to do this:
- Go to
Installed JREs
in the Eclipse Settings. - Click
Add...
- Choose “MacOS X VM” and hit
Next...
- Specify
/Library/Java/JavaVirtualMachines/<javaversion>.jdk/Contents/Home/
underJRE Home
. Note: You need to type/paste the directory directly into the field. You can’t use theDirectory...
as the directories in theJavaVirtualMachines
directory are so called “Mac OS X packages”. These directories are displayed as files and you can’t browse their contents from within the dialog. - Give the JDK a meaningful name and hit
Finish
.
Changelog ∞
What changed?
- 2011-12-30: Published
This is a tutorial to allow SAS and SPSS applications to run properly with their required versions of Java while still in compliance with SafeConnect polices needed to access the UF network.
Note if this tutorial does not work or you are unable to complete it, please visit a DHNet@Home Help desk. The locations and hours of operation can be found in the link: https://www.dhnet.ufl.edu/support/visit/
Additionally, those who feel comfortable with reconfiguring SAS can visit this link for steps on using SAS 9.3 with updated Java software. When following the steps provided, only change settings for Windows and for JRE. Residents do not need to be concerned with changing SAS for UNIX or JDK.
Step 1
Install the latest version of Java from http://java.com/en/download/index.jsp Note: If you are running a 64-Bit Platform, be sure you are installing the 64-Bit version of Java, this can be found in the left column in the link for All Java Downloads.
Step 2
Install the Java needed to run the SAS/SPSS program: Java 6 Update 24 from http://www.oracle.com/technetwork/java/javase/archive-139210.html.
Find Java 6 Update 24 among the list of Java. Accept the Licence Agreement, and download the Java SE Runtime Environemnt 6u24 for Windows
Step 3
The following step will disable the plug-in for Java 6, this will allow the SafeConnect Policy Key to run compliant. Please follow the instructions for each specific browser.
Internet Explorer
1. Open Internet Explorer
2. Type ALT+T to display the Tools menu and choose Manage Add-ons. Choose “All items” from the “Show” drop-down menu. DISABLE “Java Plug-in –version number–“. Close Internet Explorer.
3.Type WINDOWS+R and then type in regedit and navigate to HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Plug-in{VERSION}UseJava2IExplorer and DELETE ONLY the Java 6 Update 24 keys under plugin and web start.
Note: 64-bit Windows users will need to change HKEY_LOCAL_MACHINESOFTWAREWow6432NodeJavaSoftJava Plug-in{VERSION}UseJava2IExplorer
Firefox
1. Open Firefox and click the FIrefox button the top left corner > Add-Ons
2. Choose the Plug-ins tabs.
3. Select the Java plugin(s) and click DISABLE.
Google Chrome
1. Open Chrome and type chrome://plugins into the location bar.
2. Click Disable underneath the Java Plugin.
Source: http://nakedsecurity.sophos.com/how-to-disable-java-internet-explorer/