14 Replies - 10585 Views - Last Post: 23 August 2013 - 07:54 PM

#1 Flukeshot  Icon User is offline

  • A little too OCD
  • member icon

Reputation: 417
  • View blog
  • Posts: 1,030
  • Joined: 14-November 12

Java API Source Code

Post icon  Posted 25 July 2013 - 06:25 PM

Just stumbled upon a simple website to view the source code for Java APIs, including 3rd party APIs.

Although Java, as an object oriented programming language, is based upon encapsulation and cohesion, I feel it would be beneficial to the understanding of the API if implementation details were known.

If you are struggling with understanding some part of the API, I recommend reading the source. You may get some insight that helps you over the hurdle.

Link:http://www.alljavaclasses.com/

This post has been edited by Flukeshot: 25 July 2013 - 06:28 PM


Is This A Good Question/Topic? 3
  • +

Replies To: Java API Source Code

#2 farrell2k  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 858
  • View blog
  • Posts: 2,612
  • Joined: 29-July 11

Re: Java API Source Code

Posted 25 July 2013 - 07:50 PM

No 1.7 sources :(
Was This Post Helpful? 0
  • +
  • -

#3 Flukeshot  Icon User is offline

  • A little too OCD
  • member icon

Reputation: 417
  • View blog
  • Posts: 1,030
  • Joined: 14-November 12

Re: Java API Source Code

Posted 25 July 2013 - 08:04 PM

Yes, I did notice that. I do hope they update it. If anyone knows of somewhere to access Java7 sources, feel free to post it and I'll update the first post with credit to you. :)
Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,995
  • Joined: 08-June 10

Re: Java API Source Code

Posted 25 July 2013 - 09:24 PM

Doesn't the OpenJDK project implement all the standard Java APIs? Kind of has to, right, seeing as it's pretty much a stand-in replacement for Oracle's JDK on Linux systems.
Was This Post Helpful? 0
  • +
  • -

#5 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1408
  • View blog
  • Posts: 3,123
  • Joined: 05-April 11

Re: Java API Source Code

Posted 26 July 2013 - 12:57 AM

You already have the source available in your JDK directory
For my system it is C:\Program Files\Java\jdk1.7.0_25

If you don't have the source code, then you have downloaded a version without it. You can get it from oracle's website
Was This Post Helpful? 2
  • +
  • -

#6 Flukeshot  Icon User is offline

  • A little too OCD
  • member icon

Reputation: 417
  • View blog
  • Posts: 1,030
  • Joined: 14-November 12

Re: Java API Source Code

Posted 26 July 2013 - 01:21 AM

Thanks for the hint CasiOo!

You just made me discover that I had my eclipse library set up to my JRE rather than my JDK. Fixed the path variable to the JDK and wouldn't you know it. All the source code is available in my project explorer. Turns out looking to the web for the source code was an entirely useless endeavour! :crazy:
Was This Post Helpful? 0
  • +
  • -

#7 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,693
  • Joined: 13-March 10

Re: Java API Source Code

Posted 26 July 2013 - 02:01 AM

In your IDE: hover over the class you want to inspect ---> left Ctrl + Mouse Click ---> takes you to the source code.
Was This Post Helpful? 0
  • +
  • -

#8 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2045
  • View blog
  • Posts: 4,237
  • Joined: 11-December 07

Re: Java API Source Code

Posted 26 July 2013 - 04:27 AM

I quite like grepcode. Javadoc is formatted instead of code. Method names are clickable on the left and there are other options for navigating.

String class on grepcode

Usually, I just google.
Was This Post Helpful? 2
  • +
  • -

#9 farrell2k  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 858
  • View blog
  • Posts: 2,612
  • Joined: 29-July 11

Re: Java API Source Code

Posted 26 July 2013 - 07:49 AM

View PostFlukeshot, on 26 July 2013 - 08:21 AM, said:

Thanks for the hint CasiOo!

You just made me discover that I had my eclipse library set up to my JRE rather than my JDK. Fixed the path variable to the JDK and wouldn't you know it. All the source code is available in my project explorer. Turns out looking to the web for the source code was an entirely useless endeavour! :crazy:/>


I thought everyone knew this, and that you were just looking for a fun online resource. :)
Was This Post Helpful? 0
  • +
  • -

#10 Flukeshot  Icon User is offline

  • A little too OCD
  • member icon

Reputation: 417
  • View blog
  • Posts: 1,030
  • Joined: 14-November 12

Re: Java API Source Code

Posted 26 July 2013 - 08:11 AM

Bit of both actually. I did wonder why it was saying "source not found" in my System Library but I never looked into fixing it.. I found the website when I was looking for useful google chrome apps related to Java.
Was This Post Helpful? 0
  • +
  • -

#11 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7898
  • View blog
  • Posts: 13,430
  • Joined: 19-March 11

Re: Java API Source Code

Posted 26 July 2013 - 08:21 AM

It always surprises me how this stuff isn't known, but apparently most books don't mention it, and neither do most teachers.

I agree with cfoley, grepcode is probably the nicest way to put the sources up on someone else's screen if you're discussing implementations on a site like this, but how people don't know what's sitting on their own machine is simply astounding.
Was This Post Helpful? 0
  • +
  • -

#12 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10693
  • View blog
  • Posts: 39,794
  • Joined: 27-December 08

Re: Java API Source Code

Posted 27 July 2013 - 08:19 PM

So what sort of tricks do you all find interesting about peering through the source code? I like in the LinkedList class how the clear() method removes all references to the nodes to speed up garbage collection.
Was This Post Helpful? 0
  • +
  • -

#13 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2045
  • View blog
  • Posts: 4,237
  • Joined: 11-December 07

Re: Java API Source Code

Posted 28 July 2013 - 06:18 AM

Actually, that has always bothered me. It's either an optimisation we should all use on our own objects or it's not required. Its efficacy also seems dependant on the GC implementation and probably even the JIT compiler implementation.

Don't other linked data structures need this optimisation too? Apparently not.

From TreeMap which sevaral other classes extend or delegate to:
610     public void clear() {
611         modCount++;
612         size = 0;
613         root = null;
614     }


Interestingly, both TreeMap and LinkedList were written by Josh Bloch, and both classes have been there since 1.2.

This post has been edited by cfoley: 28 July 2013 - 06:19 AM

Was This Post Helpful? 0
  • +
  • -

#14 salazar  Icon User is offline

  • D.I.C Addict

Reputation: 87
  • View blog
  • Posts: 539
  • Joined: 26-June 13

Re: Java API Source Code

Posted 28 July 2013 - 06:26 PM

Awesome, what about a C++ equivalent?
Was This Post Helpful? 0
  • +
  • -

#15 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1155
  • View blog
  • Posts: 2,536
  • Joined: 05-May 05

Re: Java API Source Code

Posted 23 August 2013 - 07:54 PM

I've always used DocJar to see API code.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1