Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I view JRE's source code in Eclipse?

Tags:

java

eclipse

People also ask

How can I see predefined classes in Eclipse?

Clicking anywhere on the class name that we want to open and pressing F3. Clicking anywhere on the class name and going to the menu under Navigate > Open Declaration.

Where can I see Java source code?

Install the Java SE Development Kit from http://java.sun.com/javase/downloads/index.jsp. Once installed, you should find an archive called src. zip in the top of the JDK installation directory. The Java source code is in there.


When you are coding in Eclipse, press CTRL and click on any core Java class name in your source. Eclipse will now show a screen saying you don't have the sources installed. However, in this screen there is a link saying "Attach source...". Click that link and import the src.zip file from your JDK installation directory (src.zip). This should do the trick


You need to have the JDK installed. Then you can look in JDK_INSTALL_DIR\src.zip

For me it is C:\Program Files\java\jdk1.6.0_11\ (depends on your current version)

You don't need to get a special open source version.


There are a few good answers here on where to get the source. But a word of caution: I'd be wary about how you use it (if you're using it simply for reference). The API documentation is the only contract you should code against, and is what the developers will keep consistent/intact between releases. I wouldn't use the source find out implementation details and then code my applications with regard to those implementation details, as they may change between releases.


You should be able to see "JRE System Library [jdk1.x.xxxx]" when you look at your project's Java Build Path.

You can access the project build path configuration screen by: right clicking on the project -> Build Path -> Configure Build Path... You should be able to see the JRE System Library entry at the bottom of the list.

The easiest way to view the source for the class is to use the "Open Type" shortcut. The default for this shortcut is: Ctrl + Shift + T". The class you're looking for should appear as you type it's name.


You can go to http://openjdk.java.net/ and download the latest builds of the openJDK project. I think this should give you what you need.


For ubuntu, install openjdk-6-source and use /usr/lib/jvm/java-6-openjdk/src.zip