Java 库类的源代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2258031/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Source code for the Java library classes
提问by GuruKulki
Where can I find the source code for the Java library classes? I mean classes in rt.jar
.
在哪里可以找到 Java 库类的源代码?我的意思是在rt.jar
.
Platform: Windows.
平台:Windows。
采纳答案by Thorbj?rn Ravn Andersen
Download the JDK. The sources for the public classes are in src.zip.
下载 JDK。公共类的源代码在 src.zip 中。
回答by Pascal Thivent
Sources are in src.zip
located in the installation folder:
源src.zip
位于安装文件夹中:
On Windows, the JDK includes
src.zip
by defaultif 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.
回答by helpermethod
回答by Tal
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
如上所述,大多数源文件可以通过下载 SDK 找到。但是,对于某些类,您可以找到源代码(javax.ssl 等),因为我建议添加 jad eclipse 插件,该插件将在不使用外部站点(例如 Docjar)的情况下反编译任何类。Jad eclipse 信息:http: //jadclipse.sourceforge.net/wiki/index.php/Main_Page
回答by Ellen Spertus
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.
更新:截至 2018 年 6 月,grepcode 似乎已关闭。在这里您可以找到替代方案。
回答by djechlin
There is also grepcode.com (not sure how old this site is, perhaps this answer is an update for new solutions now), sample query:
还有grepcode.com(不知道这个网站有多老,也许这个答案现在是新解决方案的更新),示例查询:
http://grepcode.com/search?query=java.lang.Math.sin&start=0&entity=type&n=
http://grepcode.com/search?query=java.lang.Math.sin&start=0&entity=type&n=
回答by Dylan Smith
You can directly browse the code online here for Java : https://zgrepcode.com/java/openjdk/10.0.2/
您可以直接在此处在线浏览 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.
它也是浏览大多数开源项目的绝佳工具,因为它为您提供了到类的内部链接。