The importance of reading source code: such as Chef's choice of ingredients, playing kitchen utensils-How to view Java, Android source code in eclipse

Source: Internet
Author: User
Tags android sdk manager

First of all, a lot of people say, don't look at the source code in the JDK is not called learning java. Obviously that's for sure. For example: a real chef needs to choose and process the ingredients. To the final cooking, plate forming, and even finally to the user to introduce a whole set of processes such as food to go down. In fact, a lot of cooks just do a small part of it, so they can only be called "stir-fry", not a chef. And a lot of top restaurants emphasize material selection, that is, from the source to find suitable to do a dish of raw materials, and even in turn. Get a supply chain to supply a unique ingredient and specifically design some kind of cooking technology for the material.

This is the maximum utilization of resources from beginning to the beginning. Its embodiment of innovation and internal strength of the place throughout the assembly line!

In particular. The chef also needs tools, assuming that he only knows what the tool can do simply, without knowing its own characteristics, then it must not use the tools for innovative situations and scenarios.

While we are programming, of course, we can look at the corresponding class API description document to use. This is tantamount to other people to provide good material, you go stir fry.

It's no problem to fry well, of course. But you have to know the meaning behind the ingredients, but you have to stir it up. For example, understand the moisture content of the ingredients. Understand the growing environment of the ingredients and the changes in the properties that occur under different cooking conditions, and so on. In this way, your room will not be confined to a small piece.

Back to programming, when using a class, it is assumed that the implementation of its source code can be thoroughly understood. That will be more handy in later use. It is possible to rewrite a method in the source code even to satisfy a particular requirement of its own. Even rewrite its source code base. If you can provide a better class than the existing source code base, then the impact of their own innovation is not confined to an application, a set of software, but the benefit of millions of programming enthusiasts.

Said so much, in fact, from the touch of Java programming in the two or three months. I haven't really seen the source code yet. I found the information on the Internet today. Tried it:

First, take the following actions in Eclipse, for example:

1. Click "Window", "Preferences" on the left side of the pop-up list selection, "Java", "Installed JREs";

2. At this point, the right side of "Installed JREs" is the list pane. List the JRE environment in the system, select your JRE (usually there is one) and select it first. Then click "Edit ..." on the edge. A form will appear (Edit JRE);

3. Select this entry for the Rt.jar file: "%java_home_path%\java\jre_1.5.0_06\lib\rt.jar" before the path is to try your own installation path, the main look behind is "\lib\rt.jar" can be. Point to the left of the "+" number to expand it;

4. When unfolded,. Point "Source Attachment: (None)". Click the button "Source Attachment ..." On the right, and select the "src.zip" file under your JDK folder (usually under the JDK installation root folder).

Then always point "finish" and "OK" to be able to complete the source code files and Eclipse link;

Then, when the CRL is pressed in the javaproject and then clicked on the corresponding Java-brought class name, it will open to the corresponding source code file.

For Android developers, however, suppose you want to open the Java class source code of the JDK in Android project in the same way as in Android projects. It seems like I'm jumping out of the interface that can't connect to the source code (at least I am). The reason for this is that in Javaproject, Eclipse is looking for its source code file, of course, in the source file of the JDK connection. and in Android project. Eclipse is going to go to the Android SDK folder to get down. So I couldn't find it. This is the time to establish its connection in eclipse, so that you can find the source code files for Android in addition to the corresponding Java sources in Android project.

The following start configuration establishes the link:

Activity class Source: Press the CTRL key, left-click on it, the reality of the results can not see the code, the message is "can't find Activity.class file."

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvd2f5y2fpcwk=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">


1 ,   Click on the button below," Change attached Source ... ". This is jumping out of a popup box;

2, because you need to import the entire" Sources "folder under the root folder of the Android SDK, you need to Click on the pop-up box" external Folder ". Then select the "source" folder under the Android SDK installation folder. Finally click "OK". Suppose pop-up "operation  in  progress ..." description, success. complete the configuration.

3, assuming that the" source "folder cannot be found under the Android SDK installation folder, you need to start android SDK Manager for source download. After booting, tick the source for Android SDK and click "Installe package ..." in the bottom right corner to download. (or you can download it in other ways: android 4.4.2 ( API19) The latest version of the API source code , and then save to local, in the steps above to import the source directory. Select the appropriate download package to import it)

4. At this point, we open the source code of the class we want to open, whether in Android project or Java project, with a CTL and click. Can be opened to jump to the corresponding file.

The last thing we want to do is to study these tools, especially some algorithms (like the most classic sorting algorithms). Open and patiently study the course of its operation. Must be a lot of income!

The importance of reading source code: such as Chef's choice of ingredients, playing kitchen utensils-How to view Java, Android source code in eclipse

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.