Old articles-Java learning from entry to mastery

Source: Internet
Author: User
Tags object serialization ibm developerworks
For more information, see the following section. Java Learning Path

(1) Tools

I. JDK (Java Development Kit)

JDK is the core of the entire Java, including the Java Runtime Environment (Java Runtime Envirnment), a bunch of Java tools and the Basic Java class library (rt. jar ). No matter what Java application server is actually built into a certain version of JDK. Therefore, mastering JDK is the first step to learn Java well. The most popular JDK is the JDK released by Sun. In addition to Sun, many companies and organizations have developed their own JDK, such as JDK developed by IBM and Jrocket of BEA, and JDK developed by GNU. Among them, the JVM (Java Virtual Machine) Running Efficiency of ibm jdk is much higher than that of Sun JDK. The Jrocket running on the x86 platform is much more efficient on the server than Sun JDK. However, we still need to Master Sun JDK first.

1. Download and install JDK
JDK is also called J2SE (Java2 SDK Standard Edition), can be downloaded from Sun's Java website, http://java.sun.com/j2se/downloads.html, JDK is currently the latest version of J2SDK1.4.2, it is recommended to download this version of JDK, download the page at http://java.sun.com/j2se/1.4.2/download.html.

The downloaded JDK is an executable installation Program. After the installation is completed by default, a set of JRE (for use by the browser) will be installed in the C: \ Program Files \ Java \ directory. In C: \ j2sdk1.4.2 install a set of JDK (including a set of JRE ). Then we need to add the java path c: \ j2sdk1.4.2 \ bin at the beginning of the Environment Variable PATH. In this way, JDK is installed.

2. JDK command tools
JDK's most important command line tool:
Java: Start JVM to execute class
Javac: Java compiler
Jar: Java packaging Tool
Javadoc: Java document Builder
These command lines must be very familiar with each parameter. JDK Documentation provides detailed documents on how to learn these commands.

Ii. JDK Documentation

Documentation is also available on the JDK download page. We recommend that you download Documentation at the same time. Documentation is the most important programming manual, covering the description of all aspects of Java. It can be said that the majority of the time spent learning Java programming is spent reading this Documentation. I carry it with me. When I write Java code, I can check it at any time.

3. App Server)

App Server is a platform for running Java Enterprise components and forms the main runtime environment of application software. Currently, the mainstream App Server is BEA's Weblogic Server, IBM's Websphere, and free Jboss. You can select one of them for learning. I personally recommend Weblogic, because of its clean architecture and convenient development and deployment, it is the preferred development platform for Java Enterprise software developers. The following describes several common App servers:

1. Tomcat
Tomcat is not a real App Server in a strict sense. It is just a Web container that supports running Serlvet/JSP. However, Tomcat also extends some App Server functions, such as JNDI, database Connection Pool, user transaction processing, and so on. Tomcat is widely used in small and medium-sized Java Web applications. Therefore, this article introduces how to download, install, and configure Tomcat:

Tomcat is a sub-project under the Jakarta project under the Apache organization, its main website is: http://jakarta.apache.org/tomcat/, Tomcat latest version is Tomcat4.1.27, software download connection is: http://www.apache.org/dist/jakarta/tomcat-4/binaries.

To download Tomcat, you can download both the zip package and the exe installation package (I suggest you clean the zip file). In either case, after the download and installation are complete (you can decompress the zip file directly ). You need to set two environment variables:

JAVA_HOME = C: \ j2sdk1.4.2
CATALINA_HOME = D: \ tomcat4 (your Tomcat installation directory

After installation, start Tomcat to run CATALINA_HOME \ bin \ startup. bat, and close Tomcat to run the shutdown. bat script. After Tomcat is started, port 8080 is used by default. Therefore, you can use a browser to access http: // localhost: 8080 to test whether Tomcat is started properly.

Tomcat provides two management tools on the Web interface. The URLs are:
Http: // localhost: 8080/admin/index. jsp
Http: // localhost: 8080/manager/html
Before enabling these two management tools, you must manually configure the administrator user and password. Open the CATALINA_HOME \ conf \ tomcat-users.xml file with a text tool and add the following lines:





In this way, the user "robbin" has the super administrator permission. After you restart Tomcat, you can use the user to log on to the two management tools above and configure and manage Tomcat on the Web.

2. BEA Weblogic
Weblogic can download the latest Weblogic8.1 Enterprise Edition After free registration on the BEA website. License can be used for free for one year. In fact, this is enough. Weblogic download link: http://performance.bea.com/index.jsp, weblogic's on-line document: http://edocs.bea.com /.

3. IBM Webshpere
Websphere can also download to the free trial version, to IBM's developerWorks website can see the download of Websphere trial products and related Websphere information, the link of the Chinese site of developerWorks is: http://www-900.ibm.com/developerWorks/cn/wsdd, websphere download connection: http://www7b.software.ibm.com/wsdd/downloads/WASsupport.html.

4. Jboss
Jboss is a free and open-source App Server. It can be downloaded from the Jboss website for free: Ghost. There are several good Jboss configuration documents on Jdon, can be used for reference: http://www.jdon.com/idea.html

Iv. Java application Runtime Environment

Java applications can be divided into the following aspects:

1. Java Desktop applications
Desktop applications generally require only JRE support.

2. Java Web Applications
Java Web applications must install JDK, a web Container (such as Tomcat), and a multi-user database. Web applications must be divided into at least three layers:
Browser layer: displays the user page in the Browser.
Web layer: Run Servlet/JSP
DB layer: backend database that provides data access services to Java programs

3. Java Enterprise Applications
Enterprise applications are complex and can be extended to layer n. The simplest case is divided into four layers:
Browser layer: displays the user page in the Browser.
Client layer: Java Client graphics programs (or embedded device programs) directly interact with the Web layer or EJB Layer
Web layer: Run Servlet/JSP
EJB layer: runs EJB to complete business logic operations
DB layer: backend database that provides data access services to Java programs

4. Java embedded applications
Java embedded applications are an emerging field. They are engaged in Embedded Development and need to download the j2's development kit from Sun. j2's includes the dedicated virtual machine KVM for embedded devices, which is different from the JVM contained in the general JDK. You also need to download the simulator from a specific embedded vendor.

Java Learning Path (2), books

It is impossible to read only one or two books to learn a new knowledge. A step-by-step reading process is required. I recommend the Java series books published by Oreilly.

Here I just want to add one point. Many people start with Thinking in Java, but I think this book is not suitable for beginners. I think the correct way to use this book should be as an auxiliary reader. Thinking in Java is not a complete introduction to the entire Java system, but a leaping writing method, it is a method similar to tips to deeply analyze and explain many Java knowledge points.

For beginners, it is best to find a book on getting started with Java, but it introduces Java syntax, object-oriented features, core class libraries, and so on in sequence. while reading this book, let's take a look at Thinking in Java to deepen our understanding of Java and how it works. At the same time, we can fully understand the entire Java System.

For getting started books on Java, Cai xuexiao recommends Oreilly's cutting ing Java, 2nd Edition, or Java in a Nutshell, 2nd Edition (for C ++ background). I have not read these two books. In fact, I think the Electronic Industry Press's "Java 2 programming details" or "Java 2 from entry to mastery" is very good.

Among all the Java books, the most useful is not o'reilly's Java Serials. The most useful is JDK Documentation! Almost all the knowledge you want to obtain is available in Documentation. The most important part is the API Documentation of the Java basic class library, which is organized by package, each class has a detailed explanation, its inheritance relationship, whether an interface is implemented, and where can all its public attributes and methods be found, the interpretation and meaning of each attribute, the purpose of each method, the called parameter, the meaning of the parameter, the type of the returned value, and the exceptions that the method may throw. In this way, all the books on Java programming are actually just in a relatively easy-to-understand language, and a good way to introduce the usage of some classes in a package in Documentation. As a result, if you have enough ability to directly learn Java class libraries through Documentation, you do not need to read other books. In addition, Documentation is also a required manual for programming. There are three Documentation shortcuts on my desktop: Documentation of J2SDK1.4.1, Documentation of Servlet2.3, and Documentation of J2SDKEE1.3.1. With these three documentations, no other books are needed.

For Java Web programming, the core thing is to be familiar with and master the HTTP protocol, which has nothing to do with Java. After being familiar with the HTTP protocol, you need to be familiar with Java class libraries for implementing HTTP protocol, that is, Servlet APIs. The most important thing is Servlet APIs. Of course, it is very difficult for beginners to learn Web programming directly through Servlet APIs. I recommend o'reilly's Java Server Pages book to learn Web programming.

Among the EJB books, Enterprise JavaBeans, 2nd Edition is a very good book. The learning threshold for EJB is relatively high and it is difficult to get started, however, this book completely reduces the difficulty of learning. It is particularly important that the learning of EJB should be combined with the specific implementation of an App Server. Therefore, while learning EJB, you must learn an App Server synchronously. This book has three related books: Weblogic6.1, Websphere4.0, and JBoss3.0. There are both theories and practices. While learning EJB, you can view and do it while learning it, and learning EJB will become very easy.

However, this book also has a problem, that is, the old version mainly focuses on the EJB1.1 specification and some EJB2.0 specifications. The Mastering EJB 2.0 book written by Ed Roman is completely written in accordance with EJB2.0 specifications. It covers all aspects of EJB programming and has a lot of programming experience tips, it is also one of the most recommended books for learning EJB.

If you use Weblogic to learn J2EE, the J2EE application and BEA Weblogic Server is definitely the first choice. Although it is about Weblogic6.0, it is worth buying, this book is officially recommended by BEA, and the author is also an engineer of BEA. Now the Chinese version is everywhere. This book introduces the development and deployment of various J2EE technologies on the Weblogic Platform in combination with Weblogic, which has great practical guidance significance.

After having mastered the basic knowledge of the Java platform and the knowledge of J2EE, we should learn how to use the OO method to design the software, so we must learn the "Design Pattern ". Sun has published a J2EE Core Model, which is an essential book for architects who develop Java Enterprise platform software. This book comprehensively introduces various design modes of the J2EE architecture and is a must-read book for designers.

Java Learning Path (3) Process

Each person's learning method is different. One person's learning method is not necessarily suitable for another person. I can only talk about my learning method. Because I learned Java completely by myself and never asked anyone, the learning process was basically entirely self-developed. I don't know whether this method is a good one. I can only provide you with some reference.

The first step to learning Java is to install JDK and write a Hello World ,? In fact, JDK learning is not that simple. There are two problems with JDK that are easily plagued by Java programmers: one is the CLASSPATH problem. In principle, it is necessary to understand how the JRE ClassLoader loads the Class, the package and import problems, and how to find the Class path. By clarifying these two problems, we have removed the biggest obstacle to learning Java and using JDK. We recommend that you take a look at Wang Sen's "Java deep Adventure" and discuss these two issues in depth.

The second step is to learn the Java syntax. Java syntax is similar to C ++. Basically, the mainstream programming languages are not class C, but class C ++. There is no new things, so the syntax is learned, about half a day is enough. The only thing to note is that there are several keywords that are not easy to understand: public, protected, private, static, when to use, why to use, and how to use, it may take a long time for someone to give me some advice. But later I saw Thinking in Java, which mentioned these concepts.

The third step is to learn the features of Java's object-oriented programming language. For example, inheritance, constructor, abstract class, interface, method polymorphism, overload, overwrite, and Java exception handling mechanism. For a person without an object-oriented language background, I think this process takes a long time, because I have no C ++ experience before learning Java and only C experience, it took me about a month to fully understand these concepts. I tried to repeat, modify, and try the examples in the book and read them over and over again, after reading the past, I had to read it five times before I fully realized it. However, I think if I have C ++ experience, it may take a day or two. In this process, you can read Thinking in Java and have a deep understanding of OO's thoughts.

Step 4: Get familiar with Java class libraries. The Java base library is the jre \ lib \ rt. jar package under the JDK installation directory. Learning the basic library is to learn rt. jar. There are many classes in the basic class library. It is said that there are more than 3000, and I have not made any statistics. But for us, there are only four at the core:
Java. lang .*;
Java. io .*;
Java. util .*;
Java. SQL .*;

The four packages of learning, each of which can be written as a thick teaching material, and o'reilly does. I think it is impossible to study by reading four books if the time is too short. I think the better way to learn is as follows:
First, read the entire package framework and understand the composition of the class, interface, and exception of the entire package. It is best to find an article about the entire package framework. The first few chapters of these books that specifically introduce the package should be the introduction of these general frameworks.

Understanding the overall framework of the package is not to be familiar with the usage of each class. Remember what attributes and methods it has. I cannot remember it. Instead, you need to know what types of packages constitute, what are the purposes of these classes, and what functions are completed by the core classes. During training, I usually talk about a package in a class, so it is impossible to describe the usage of each class in detail. However, I have repeatedly stressed that, what I want to tell you about these packages is not to tell you how class methods are called, nor to remember the class method calls, but to understand, java provides us with classes, where each class is used, and when I encounter a problem, I know which class or which combination of classes can solve my problem, that 'all !, When writing a program, you only need to know which class to use to complete your work. When coding, the specific method call is to write code while querying Documentation. Everything is in Documentation. You do not need to remember it, in fact, you cannot remember nearly 3000 method calls for more than 0.1 million classes. Therefore, it is extremely important to grasp the overall framework of each package.

Step 5: Through the above study, if the learning is solid, it will lay the foundation for Java, the rest of the work is to clear some useful classes except the above four packages in Documentation. I believe that the progress has reached this step, and Java's self-learning capability has been developed. Now we can directly learn Documentation. In addition to GUI programming, other useful packages in JDK are:
Java. text .*;
Java.net .*;
Javax. naming .*;
There are actually few classes in these packages, so it does not take a lot of time.

Step 6: Java Web programming. The core of Web programming is HTTP. HTTP has nothing to do with Java. If you are not familiar with HTTP, you can also learn Servlet/JSP programming well, however, it cannot reach the level of perfection. Therefore, learning the HTTP protocol is essential. If I am familiar with the HTTP protocol and have a good foundation for Java programming, it would be easy to learn Servlet/JSP. It took me less than a week to learn Servlet/JSP, then we started to use JSP for the project.

In Servlet/JSP learning, the beginning is still Servlet Documentation. The most common classes of Servlet APIs are very few, so it takes a little time to master them. Read all these classes and write several more examples. The essence of Servlet/JSP programming is to call these classes repeatedly to communicate with the Web Server and Brower over HTTP. In addition, for JSP, you also need to be familiar with several common JSP tags. If the specific writing method cannot be remembered, you can temporarily check the tags.

In addition, the focus of Java Web programming learning should be on the Design Pattern of Web applications. How to analyze the business logic and make rational design, in accordance with the requirements of the MVC design pattern, use Servlet and JSP to complete different logic layers, Master how to control the process and share data between Servlet and JSP, and how to configure and deploy Web applications.

Step 7: J2EE Programming
If the above learning process is relatively smooth, the difficulty increases sharply. Because the above knowledge only involves one aspect, and core J2EE specifications such as EJB, JMS, and JTA are often the result of the comprehensive application of several Java technologies, therefore, it is difficult to master.

First, you must learn the JNDI. The JNDI is the method used by the App Server to locate Server resources (EJB components, Datasouce, JMS). If you are not familiar with JNDI, EJB, JMS is almost impossible to learn. JNDI is actually the javax. naming. * package, which is easy to use. The difficulty lies in the configuration of server resource files. For the server resource file configuration, you need to look at the specific documentation specifications, such as web. xml writing, ejb-jar.xml writing and so on. You need to be familiar with each different App Server and its own service resource configuration files.

Then we can learn about JTA, mainly to understand the JTA's method of controlling transactions, and where to use JTA. Here is a simple example. We know that transaction control (conn. setAutoCommit (false ),...., conn. commit () is used as an atomic operation, but if my business needs to use operations on two different databases as an atomic operation, can you do it? At this time, only JTA can be used. Assume that the operation first inserts A record into database A and then deletes another record in database B. We cannot control the entire operation as an atomic operation by writing code on our own. If JTA is used, the App Server controls it.

Before learning EJB, you need to learn Object serialization and RMI. RMI is the foundation of EJB. Next, we will learn about JMS and ejbs. The most important thing for ejbs is to understand how ejbs call remote objects through RMI, and under what circumstances to use ejbs.

After learning about EJB and JMS, you may realize that you need to learn more about the two fields: UML and Design Pattern. Java Enterprise software design attaches great importance to Framework Design. A good software Framework is a necessary condition for successful software development. At this time, we should begin to focus on the learning of the design mode and framework, and master the EJB Design Mode and the core mode of J2EE through learning and practical programming experience.

In the J2EE specification, there are many enterprise technologies in addition to EJB, JMS, JTA, Servlet/JSP, and JDBC, which are not described here.

There is also a new field of Web Services. Web Services does not have any new things at all. It is like a binder. Different Services can be unified to provide a unified call interface. for users, I only need to obtain the WSDL (service description) provided by the service provider. I have no idea whether the service provided by the server provider is an EJB component or. I don't need to know about the Net component, what is the CORBA component, or other implementations. The greatest part of Web Services lies in the sharing of Internet Services by means of unified service provision and calling. It is a very exciting technical field. Web Services does not seem to have any good books yet, but you can learn it by checking information on the Internet.

Java Learning Path (4) Method

Java as a programming language, the best way to learn is to write code. After learning a class, you can write a simple example program to run it to see what the result is, and then call several more class methods to see the running result, in this way, the class is learned intuitively and the memory is very deep. The code should not be called. You should think about it. If I don't write it like this, try again. I remember which expert said that learning programming is a process of destruction. After running the examples in the book and learning the examples compiled by Documentation, he constantly tries to implement them in different ways, constantly try to break the code structure and see what results it will have. In this way, you will have a thorough understanding of Java.

For example, we have compiled Hello World.


Public class HelloWorld {public static void main (String [] args) {System. out. println ("Hello World ");}}


Many beginners do not quite understand why the main method must be defined as public static void main (String [] args) in this way. Can it be written like this? This includes questions when I first learned Java. Do you want to know the answer? It is very simple. You should change the main name to run it to see what errors are reported and analyze them based on the error information. Remove the public of main and try again to see what errors are reported; static removal can still be run; do not know if the main method must pass a String [] array, change String [] to int [], or try it out; if you do not know whether to write the args parameter name, you can also change the args to another name to see how the running result works.

This is what I did when I first studied Java. I modified the Hello World Program seven or eight times and kept running and analyzed the running results, finally, I fully understand why the main method is defined in this way.

In addition, I didn't understand staic, public, private, Exception, try {} catch {} finally {} and so on at the beginning. They all succeeded in running the example above the reference books, then, I began to destroy it and constantly rewrite the program based on my questions to see if it could run, what it was like to run, and whether it could get the expected results. This is time-consuming, but an example program is destroyed several times in this way. I have completely learned the relevant knowledge. Sometimes you may even intentionally write some wrong code to run it and see if you can get the expected running error. In this way, we have a profound understanding of programming.

Among them, it is particularly worth mentioning that JDK has a very good debugging function,-verbose
Java? Verbose
Javac? Verbose and many other JDK tools have this option.
-Verbose can display the classes loaded by the JVM in sequence during command execution. Through these valuable debugging information, this helps us analyze what the JVM has done during execution.

In addition, many of the destructive routines you write during the learning process should be consciously stored in different categories, and the typical routines accumulated in your work should also be sorted regularly, you have a code library. If you encounter similar problems, just Copy & Paste, Search & Replace in the code library, which greatly improves the development speed. The ideal situation is to abstract some common routines to form a common class library and encapsulate them. The reusability is enhanced.

So I don't think it is really a special routine. The destroy routine you write is the best example. If you are not at ease with the code you write, I strongly recommend that you check the Java source code of the JDK base class library. There will be a src.zip under the JDK installation directory, and you can see the entire JDK base class library, that is, rt. jar Java source code. You can refer to how Sun writes Java programs and what the specifications look like. When I am learning Java class libraries, when I do not understand them clearly or want to understand the operation details more clearly, usually open the source code of the corresponding class. by looking at the source code, all problems will be swept away.

Java Learning Path (5) Resources

1. http://java.sun.com)
Sun's Java website should be visited frequently. Needless to say.

2. http://www-900.ibm.com/developerWorks/cn/
For the IBM developerWorks website, go to the English site. This is not only an excellent Object-Oriented Analysis and Design website, but also an excellent website for Web Services, Java, and Linux. It is strongly recommended !!!

3. http://www.javaworld.com)
Discussions and news about many new Java technologies. I 'd like to know more about all aspects of Java, which is better here.

4. http://dev2dev.bea.com.cn/index.jsp
BEA's developer field, BEA, as the most important App Server vendor, has many unique technologies that can be missed by partners who develop on Weblogic.

5. http://www.huihoo.com/
The gray fox power website, a professional middleware website, is not a professional Java website, but has profound accomplishments in J2EE enterprise application technology.

6. http://www.theserverside.com)
TheServerSide is a famous website dedicated to Java Server applications.

7. http://www.javaresearch.org/
The Java research organization has many excellent articles and tutorials on Java, especially in JDO.

8. http://www.cnjsp.org/
JSP technology websites have a considerable number of Java articles and resources.

Http://www.jdon.com/
Jdon forum is a personalized Chinese J2EE Professional Technology Forum. Among the many Java Chinese forums, Jdon is a forum with high technical content and excellent post quality.

Http://sourceforge.net/
SourgeForge is the base camp of open source software, which also has a very rich set of Java open source famous software.
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.