Source code for the Java library classes - java

Where can I find the source code for the Java library classes? I mean classes in rt.jar.
Platform: Windows.

For old versions of Java with separate JRE and JDK downloads, download the JDK. The sources for the public classes are in src.zip.

Here's the browsable source code for OpenJDK 7.
Update: As of June 2018 grepcode seems to be down. Here you can find an alternative.
Update^2: As of October 2020, the two previous links do not work. View it at OpenJDK and vote up the answer by Nosrep, which I got it from.

Sources are in src.zip located in the installation folder:
On Windows, the JDK includes src.zip by default if I remember well.
On a Linux distro, you may have to install the sun-java6-source package.
On Mac, you'll have to download the Developer Documentation. Have a look at this answer.

If you only need to have a look at the source/implemenation, i would suggest using
Docjar
Edit
GrepCode is even better
GrepCode

You can directly browse the code online here for Java : https://zgrepcode.com/java/openjdk/10.0.2/
It is a great tool also for browsing most of the open source projects as it gives you internal linking to classes.

As almost all the suggestions seem to be either grepcode or zgrepcode which are both down, I found one from OpenJDK here: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/tip/src/share/classes/
Edit: a more complete version of all OpenJDK projects and JDK 6-15 can be found here: https://hg.openjdk.java.net/

As mention above, most of the source files can be found by downloading the SDK.
However for some classes you can find the source code (javax.ssl etc') for I suggest adding the jad eclipse plugin that will decompile any class without using external site such as Docjar.
Jad eclipse info:
http://jadclipse.sourceforge.net/wiki/index.php/Main_Page

There is also grepcode.com (not sure how old this site is, perhaps this answer is an update for new solutions now), sample query:
http://grepcode.com/search?query=java.lang.Math.sin&start=0&entity=type&n=

Related

ClassNotFoundException / org.apache.pivot.wtk.BrowserApplicationContext$HostApplet

Is there any version of JAVA, or an alternative to JAVA, which is compatible with dial-up. I keep getting the following exception even when using Google Chrome or FireFox.
ClassNotFoundException / org.apache.pivot.wtk.BrowserApplicationContext$HostApplet
I have the latest JAVA Version. Are there any older versions still available? JAVA.com does not seem to have it's own customer support centre
Everything else out there is either pay-by-the-minute or "buy our fix-it program"
Not all existing Java libraries are included in the JDK. You seem to have a piece of code which refers to a library called Apache Pivot. You need to make sure that you have the jar file(s) for this library and that they are in your CLASSPATH when you execute your program. I think you need to find a good book or tutorial.
Instead of including your library to the CLASSPATH environment variable you can also copy the external jar-files to your jdk and jre.
On my system thats for example:
C:\Program Files\Java\jdk1.7.0_21\jre\lib\ext\
and
C:\Program Files\Java\jre7\lib\ext\
I have better experiences with that, than setting the CLASSPATH.

complete java class library source code on osx

I've got the incomplete sources, courtesy of the official JDK download from apple. Its missing things like com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl, which is of course what I need to step into.
Is there a convenient source jar available? I found one for b14, but the sources for that file don't match.
I went and got the OpenJDK sources (b25 is latest apparently) but it would appear to need a bunch of other things downloaded and then assembled and I'm loath to attempt that on OSX.
The OSX version claims to be 1.6.0_33.

Where can I find the package javax.media.opengl?

I need to import the javax.media.opengl.* package. From Java OpenGL Wiki to http://jogamp.org/, I am sort of confused which download I need. There is a long list of build downloads here, but they are all .7z files and I am looking for a download usable for a Windows XP 32-bit machine.
This answer is outdated. JOGL has changed the package name.
javax.media.opengl is now com.jogamp.opengl
be aware if you have an old project and you try to get the latest library version.
You only need two packages for java OpenGL:
jogl.all.jar -> this contains javax.media.opengl.
gluegen-rt.jar -> this contains com.jogamp.opengl.
Both of which are in here: jogamp-all-platforms.7z
http://jogamp.org/deployment/jogamp-current/archive/
Edit
They seem to have reorganized their site. I updated the link.
The 7z archive format can be extracted with 7-zip, which is available on Windows.

Versions of libraries included in the JDK

I just ran into a problem with the version of JAX-WS in JDK 1.6.0 being different than the one in JDK 1.6.0_14.
I've been searching around for a list of the various libraries that are packaged in the JDK that shows the versions of the library included in the version of the JDK.
I haven't had any luck yet.
Is there such a list?
Usually this information can be found by digging around in the JavaDocs for the release (not the API docs, but the release notes and spec notes (e.g. for Java 6 ). It's in there somewhere, but sometimes that kind of info is tricky to find.
It is probably in JSR 270 (http://jcp.org/en/jsr/detail?id=270) which defines exactly what is Java6. But I havent checked and JSR are not the most pleasant readings ;-)
Have you tried looking inside the jar file?
In the META-INF folder is a file called manifest.xml which might contain version information. Some vendors do this (e.g. Oracle's JDBC driver has this), but some don't.

Location of 1.5.x JDK source code

I have installed Eclipse 3.3 on Mac OS X and it does not contain the src.zip file I am used to seeing with Windows and Linux installations. Where can I download the complete source code for the Java 1.5 JDK (must be specific versions).
I have been able to locate the full source code, however it contained the ungenerated Buffer implementations and so navigating NIO code was not possible.
Looking for the Java source typically found in the JDK src.zip, not the VM source.
You can get the Developer Documentation, which includes the source. The download requires you to have an ADC account.
Brian Clapper has already mentioned it in a comment, but the JDK downloads from Sun include src.zip. I don't know if there's any way to get it other than installing on a target platform, but you can install it on a Windows or Linux (virtual) machine and get src.zip from there.
Specifically for Java 1.5, the downloads are here
[Update]
Also, source distributions of the JDK are available from Sun from here. It seems that SCSL link is messed up and throws you for a loop, but JRL still works (if you don't mind going through it).
It is located in
/System/Library/Frameworks/JavaVM.framework/Versions.1.5.0/Home/src.jar
I do have the XCode stuff installed found on the installation disks that come with a Mac, so I don't know if the source code appears on a standard Mac installation of OSX.
/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/src.jar
More details on:
http://confluence.concord.org/display/CCTR/Get+local+copies+of+Mac+OS+X+Java+source+code+and+Javadoc
Unclear if that is even possible since the Mac JDK is not, to my knowledge, open source. It was created by Apple not Sun.

Categories

Resources