score:84

Accepted answer

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.

score:0

you can use 'eclipse class decompiler integrates jd, jad,' from eclipse marketplace.

from the find box in the eclipse marketplace write: 'jad' and you would find it.

score:0

src.zip file is present in installed jdk folder : ..\program files\java\jdk1.8.0_131

provide this path on the screen showing attach source... worked for me.

score:0

we can see c:\program files\java\jdk1.8.0_73\src.zip where c:\program files is a home directory where i have installed the java.

in eclipse, it will show like source not found. form there link will come like browse source. browse the link c:\program files\java\jdk1.8.0_73\src.zip and attach it. now you can see your source code.

score:0

@jjnguy suggestion worked for me. but make sure you have also changed the default compiler as well. right clickon th project-->java compiler->click on the link under jdk compliance(right section).

score:1

outside eclipse you can see the jdk sources on javasourcecode.org. on this page you can switch from the oficial api documentation to the source code and viceversa.

score:3

if you can't find the actual source you can also use a decompiler to regenerate source from the class file.

personally i use jad combined with the jadclipse plugin to view source in eclipse.

score:3

right click on the project -> build path -> configure build path. now edit your jre > select 2nd option alternate jre -> select any jdk (not jre). finish, now open any class by ctrl + click, its source code will display.

score:4

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

score:5

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.

score:6

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.

score:9

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.

score:95

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


Related Query

More Query from same tag