Where to find Java JDK Source Code?

I would like to see what a method in the Java API does. So I want the JDK Source Code. Before I re-installed Linux I had the src.zip package with all the official source code in it. I just had to tell Eclipse where this file is and I could see the code. But now I don't have the file anymore...

So the question is: Where can I find it?


You haven't said which version you want, but an archive of the JDK 8 source code can be downloaded here, along with JDK 7 and JDK 6.

Additionally you can browse or clone the Mercurial repositories: 8, 7, 6.


Chances that you already got the source code with the JDK, it is matter of finding where it is. In case, JDK folder doesn't contain the source code:

sudo apt-get install openjdk-7-source

OSX Folks, search in homebrew formulas.

In ubuntu, the command above would put your souce file under: /usr/lib/jvm/openjdk-7/

Good news is that Eclipse will take you there already (How to bind Eclipse to the Java source code):

Follow the orange buttons

在这里输入图像描述在这里输入图像描述在这里输入图像描述


Sadly, as of this writing, DESPITE their own documentation readme, there is no src.zip in the JDK 7 or 8 install directories when you download the Windows version .

Note: perhaps this happens because many of us don't actually run the install .exe, but instead extract it. Many of us don't run the Java install (the full blown windows install) for security reasons....we just want the JDK put someplace out of the way where potential viruses cannot find it.

But their policy regarding the windows .exe (whatever it truly is) is indeed nuts, HOWEVER , the src.zip DOES exist in the linux install (a .tar.gz). There are multiple ways of extracting a .tar and a .gz, and I prefer the free "7Zip" utility.

  • download the Linux 64 bit .tar.gz
  • use 7zip to uncompress the .tar.gz to a .tar
  • use 7zip to extract the .tar to the installation directory
  • src.zip will be waiting for you in that installation directory.
  • pull it out and place it where you like.
  • Oracle, this is really beyond stupid.

    链接地址: http://www.djcxy.com/p/92130.html

    上一篇: Java本地方法源代码

    下一篇: 在哪里可以找到Java JDK源代码?