1

Is there any web site that I could see the source code for the Java standard library? Most so the two classes java.lang.* and java.net.* ??

sixxvirus
  • 39
  • 1
  • 4
  • 2
    Of course, the vast majority of `Object` is `native` functions not in the *Java* source code (but rather the C code of the JVM)... – T.J. Crowder May 13 '12 at 08:51
  • 1
    Possible duplicate: http://stackoverflow.com/questions/2026093/is-jvm-open-source-code-if-not-how-can-i-get-code-of-jvm – Alex K May 14 '12 at 06:52

4 Answers4

4

Please install Java JDK (Java Developer Kit), which is not the same as Java JRE (Java Runtime Environment).

The Java JDK contains the Java source code.

And you'd better to use an IDE (Integrated Development Environment) such as Eclipse or NetBeans to develop Java programs.

You can look for the java code via the IDE tool.

Martijn Courteaux
  • 67,591
  • 47
  • 198
  • 287
user1112699
  • 197
  • 3
3

Of course. You could find it in the JDK, but also online. I also use the online version, because I find it faster as to open the folder with the JDK, brows through all the files and so on. Just google "java source object".

http://www.docjar.com/html/api/java/lang/Object.java.html

Thomas Uhrig
  • 30,811
  • 12
  • 60
  • 80
  • 1
    I'd recommend [grepcode](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/Object.java), it's the sh*t these days. Hyperlinked code, find derived items, find usages, highlight all occurrences in file, ... – Marko Topolnik May 13 '12 at 08:57
  • @Marko Topolnik nice site! It is even with FindBugs annotations! – Thomas Uhrig May 13 '12 at 09:00
  • @StephenC that's just a colloquialism, but I guess the standards here frown even upon that. – Marko Topolnik May 13 '12 at 09:00
  • I went on the site, I only see code for java.lang. I do not see the java.net package of the library. – sixxvirus May 13 '12 at 09:06
1

You need the JDK (JAVA SDK) installed and source of class library is at (on Windows):

C:\<Program Files>\Java\<JDK>\src.zip

Like

C:\Program Files\Java\jdk1.7.0\src.zip
David Oliván
  • 2,717
  • 1
  • 19
  • 26
0

Java source code is available in JDK distribution. If you have installed JDK on your machine, in JDK directory you'll find src.zip. For example, in my windows machine source code is available at: C:\Program Files\Java\jdk1.6.0_12.

Alternatively, you can find Java source code online at: Java Source Code

Thanks, Mrityunjoy

fiveelements
  • 3,649
  • 1
  • 17
  • 16