view java source code

前端 未结 6 1999
Happy的楠姐
Happy的楠姐 2020-12-08 21:41

Is any way to view the actual code behind the default classes in Java (java.awt.*;, javax.swing.*;, etc) to see exactly what it is that is

相关标签:
6条回答
  • 2020-12-08 21:53

    I frequently use http://docjar.com for this purpose.

    Example: I want to see the source code for String. Search for the FQCN, java.lang.string (using the "Package/class Name" option). Click the result you want, then click the source link at the top of the page. Voila: http://www.docjar.com/html/api/java/lang/String.java.html

    0 讨论(0)
  • 2020-12-08 21:53

    1) Use Eclipse to attach the source code in C:\users\program files\jdkx.x
    2) Use GrepCode if you are just browsing the code and to save memory used by heavy weight eclipse on your machine

    0 讨论(0)
  • 2020-12-08 22:00

    I also find http://www.codeatlas.com to be a great place to look for JVM based source code in general. For example, if you are ever looking for how java.awt.ActionEvent is implemented you can find it here:

    http://www.codatlas.com/project/L_fXVCOhW4_lzXEd3R5DNQ__/master/src/share/classes/java/awt/event/ActionEvent.java?keyword=ActionEvent&line=59

    What's nice about it is that it gives an IDE like browsing experience by adding cross-reference and syntax highlighting.

    0 讨论(0)
  • 2020-12-08 22:04

    For those who use linux distributions, like ubuntu, archlinux, etc. You can always get openjdk source code via corresponding package management system. This means you can choose a faster mirror to get the source code.

    For ubuntu users:

    $ sudo apt-get install openjdk-7-source
    

    For Archlinux users:

    $ sudo pacman -S openjdk7-src
    

    The source will be located in the $JAVA_HOME, somewhere like /usr/lib/jvm/java-7-openjdk/src.zip.

    Other distributions will have likewise package names, so not listed here.

    0 讨论(0)
  • 2020-12-08 22:08

    src.zip usually comes with JDK.

    0 讨论(0)
  • 2020-12-08 22:14

    The Java source code for all the API classes is shipped in the JDK installer in a file named src.zip. It's often just sitting in your install directory. Unzip it, and have a look.

    If it's not there, you may have chosen not to install it; reinstall the JDK and watch for the "source code" option, making sure to include it.

    0 讨论(0)
提交回复
热议问题