Read the importance of source code: for example, the chef selects food ingredients and plays kitchen utensils-how to view the Java and Android source code in Eclipse, eclipseandroid
First of all, many people say that they will not learn Java without looking at the source code in jdk. Obviously, this is positive. For example, a real cook needs to go through a complete set of processes from Food Ingredients selection, processing, cooking, loading, and even introducing the food methods to users. In fact, many chefs only make a small part, so they can only be called "fried food" at most, rather than a cook. Many top-level restaurants emphasize the selection of materials, that is, to find the raw materials suitable for a dish from the source, or even vice versa, to get a supply chain to supply a Unique ingredient and design a certain cooking technology for the material. This is the best use of resources from the beginning to the end. It reflects innovation and internal strength throughout the entire pipeline! In particular, chefs also need to use various tools. If they only know what the tool can do, but do not know its own characteristics, they must not use the tools in innovative occasions and scenarios.
While programming, we can certainly look at the corresponding class API instructions for use. This is tantamount to providing materials for others. Of course, it is okay to fry well, but you have to understand the meaning behind the ingredients. For example, you can understand the water content of food ingredients, the growth environment of food ingredients, and the attribute changes that occur under different cooking conditions. In this way, you will not be limited to a small block.
Back to programming, when using a class, if you can have a deep understanding of its source code implementation method, it will be more handy in future use. You can even rewrite a method in the source code or its source code library to meet your own special needs. If you can provide a better class than the existing source code library, the influence of your own innovation is not limited to an application or a set of software, but for the benefit of thousands of programmers!
Having said so much, I have not really seen the source code in the past two or three months of Java programming. Today, I found the following information online and tried it:
First, perform the following operations in Eclipse:
1. Click "window"-> "Preferences". In the displayed left-side Navigation Pane, choose> "Java"-> "Installed JRES ";
2. in this case, the right side of "Installed JRES" is the List Pane, listing the system's JRE environment. Select Your JRE (usually one here), select it, and click "Edit... ", a window appears (Edit JRE );
3. select rt. jar file: "% JAVA_HOME_PATH % \ java \ jre_1.5.0_06 \ lib \ rt. the path above jar is determined by your own installation path. It mainly depends on "\ lib \ rt. jar. Click "+" on the left to expand it;
4. after expansion, click "Source Attachment :( none)" and click "Source Attachment... ", select the" cmdsrc.zip "file under your JDK directory (usually in the jdk installation root directory ). Click "finish" and "OK" to link the source code file to Eclipse;
In this case, press crl in the Java project, and then click the class name that comes with the corresponding Java to open the jump to the corresponding source code file.
However, for Android Developers, if they want to open the Java source code of jdk In the android project in the same way, it seems that the interface cannot be connected to the source code (at least I do ). The reason should be that in the Java project, the source code file for Eclipse is of course found in the source code file for jdk connection. In the Android project, Eclipse searches for the Android SDK directory. So I still cannot find it. At this time, we need to establish a connection in Eclipse, so that in addition to finding the corresponding Java source code file in the android project, we can also find the android source code file. Configure the link as follows:
Source code of the Activity class: press Ctrl and left-click it, but the actual result cannot see the code. The prompt message is "Activity. class file not found ".
1. click the button below, "Change Attached Source ...", This is a pop-up box;
2. to import the entire "sources" Folder under the root directory of the Android SDK, click "external Folder" in the pop-up box ". Then select the "source" folder under the Android SDK installation directory. Click "OK ". If "operation in progress..." is displayed, the operation is successful. Complete the configuration;
3. If the "source" folder cannot be found in the Android SDK installation directory, start Android SDK Manager to download the source code. After the sdk is started, check the source for Android sdk and click "installe package..." in the lower right corner to complete the download. (Or you can download it in other ways and save it to your local device. In the above steps, import the source code folder and select the corresponding download package for import)
4. At this point, no matter in the Android project or Java project, we can open the source code of the class we want to open by adding ctl and clicking, you can open and jump to the corresponding file.
Finally, we need to study these tools, especially some algorithms (such as the most classic sorting algorithms ). After opening it, You can patiently study its implementation process, which will surely benefit a lot!