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 happening?
I don't mean just the documentation, or a list of methods, etc, but the source code itself in full detail (in other words, what could be used to create an exact copy of an entire method/class if copied and pasted into the code for a program in Java).
Install the Java SE Development Kit from http://java.sun.com/javase/downloads/index.jsp. Once installed, you should find an archive called src. zip in the top of the JDK installation directory. The Java source code is in there.
Go to Windows->Preferences->Java->Installed JREs. Select Browse and navigate to the C:\Program Files\Java\jdk1. 6.0_21 directory. Eclipse will automatically find the source and associate it with the JDK classes.
A View is a Java Class that inherits directly from the Java Object class, the root of the Java class hierarchy. Views are the basic building block for all Android GUI elements, and serve as the base class for all GUI widgets.
Source code is the set of instructions and statements written by a programmer using a computer programming language. This code is later translated into machine language by a compiler.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With