Programming Learning: Java learning from getting started to mastering

Source: Internet
Author: User
Tags abstract exception handling execution net object serialization version java web jboss
Programming Java Learning Path (i), tools


One, JDK (Java Development Kit)

The JDK is the core of the entire Java system, including the Java Runtime Environment (Java Runtime envirnment), a stack of Java tools and a Java-based class library (Rt.jar). No matter what Java application Server is in essence a version of the JDK is built in. So mastering the JDK is the first step in learning java. The most mainstream JDK is the JDK that Sun releases, and many companies and organizations, in addition to Sun, have developed their own JDK, such as the Jrocket of IBM's Jdk,bea company, the JDK developed by the GNU organization, and so on. IBM's JDK contains JVM (Java Virtual Machine) that is much more efficient than the JVM contained in the Sun JDK. The Jrocket, which runs on the x86 platform, is also much better at the server than the Sun JDK. But anyway, we need to get the sun JDK first.

1, the JDK download and install
The JDK, also known as J2SE (Java2 SDK Standard Edition), can be downloaded from the Sun's Java Web site, http://java.sun.com/j2se/downloads.html, The current version of the JDK is j2sdk1.4.2, and it is recommended that you download this version of the JDK, download the page here: http://java.sun.com/j2se/1.4.2/download.html.

The downloaded JDK is an executable installer that installs a set of JRE (for browsers to use) under the C:\Program files\java\ directory after the default installation, and installs a set of JDK (also includes a JRE) under C:\j2sdk1.4.2. Then we need to add the Java path C:\j2sdk1.4.2\bin to the front of the environment variable path. So the JDK is installed.

2, the JDK command tool
The most important command-line tool for JDK:
Java: Start JVM execution class
Javac:java compiler
Jar:java Packaging Tools
Javadoc:java Document Builder
These command lines must be very, very familiar and proficient for each parameter. For the learning of these commands, the JDK documentation has detailed documentation.


Second, JDK documentation

Documentation also has a download link on the JDK download page and recommends downloading documentation at the same time. Documentation is the most important programming manual, covering all aspects of the entire Java description of the content. It can be said that learning Java programming, most of the time is spent looking at the documentation above. I was carrying, write Java code, at any time to view, a moment of the hand.


Third, Application server (app server)

App Server is a platform for running Java Enterprise Components, which forms the main operating environment of the application software. The current mainstream app server is Bea's WebLogic server and IBM's WebSphere and free JBoss, choose one to learn from, and personally recommend WebLogic, because its architecture is cleaner, Development and deployment is more convenient, is the Java enterprise Software developers preferred development platform. The following is a brief introduction to several commonly used app servers:

1, Tomcat
Tomcat is not strictly a true app server, it's just a web container that can support running serlvet/jsp, but Tomcat also extends the functionality of some app servers, such as JNDI, database connection pooling, user transactions, and so on. Tomcat is very widely used in small and medium scale Java Web applications, so this article does a little bit of downloading, installing, and configuring Tomcat:

Tomcat is a subproject under the Jakarta Project under the Apache organization, and its main web site is: http://jakarta.apache.org/tomcat/, The latest version of Tomcat is Tomcat4.1.27, the software download connection is: http://www.apache.org/dist/jakarta/tomcat-4/binaries/.

Tomcat can download either the ZIP package directly, or the EXE installation package (personal suggestion zip cleaner), in either case, after the download is installed (Zip Direct decompression can be.) Two environment variables need to be set:

java_home=c:\j2sdk1.4.2
CATALINA_HOME=D:\TOMCAT4 (your Tomcat installation directory)

This is installed, start Tomcat run Catalina_home\bin\startup.bat, turn off Tomcat run Shutdown.bat script. After Tomcat is started, the 8080 port is used by default, so you can use the browser to access http://localhost:8080 to test whether Tomcat starts properly.

Tomcat provides management tools for two web interfaces, respectively:
http://localhost:8080/admin/index.jsp
Http://localhost:8080/manager/html
Before enabling these two administrative tools, you need to manually configure the administrator user and password. Open Catalina_home\conf\tomcat-users.xml This file with a text tool and add the following lines:

<role rolename= "Manager"/>
<role rolename= "admin"/>
<user username= "Robbin" password= "12345678" roles= "Admin,manager,tomcat"/>

This allows the user "Robbin" to have Super Administrator privileges. After you restart Tomcat, you can use the user to log on to the two administrative tools on the Web for Tomcat configuration and management.

2, BEA Weblogic
WebLogic can go to Bea's website for free and download to the latest Weblogic8.1 Enterprise Edition, license can use 1 years free, in fact, this is completely enough. WebLogic Download Connection: http://commerce.bea.com/index.jsp,.../edocs.bea.com/.

3, IBM Webshpere
WebSphere can also download to the free trial version, to IBM's Developerworks Web site can see the WebSphere Trial product downloads and related WebSphere information, developerworks Chinese web site connection is: http ://www-900.ibm.com/developerworks/cn/wsdd/, WebSphere Download connection: http://www7b.software.ibm.com/wsdd/... Wassupport.html.

4, Jboss
JBoss is a free and open source app Server that can be downloaded free from the JBoss Web site: http://www.jboss.org/index.html, ... n.com/idea.html


Four, Java application of the operating environment

Java applications can be easily divided into the following areas:

1, Java Desktop applications
Desktop applications typically require only the support of the JRE to be sufficient.

2. Java Web Application
Java Web applications require at least a JDK and a web container (such as Tomcat), as well as a multiuser database with at least three tiers of Web applications:
Browser layer: Browser Display user page
Web layer: Running servlet/jsp
DB layer: Back-end database, providing data access services to Java programs

3, Java Enterprise-class application
Enterprise-class applications are more complex, can be extended to n-tier, the simplest case will be divided into 4 layers:
Browser layer: Browser Display user page
Client layer: Java Client graphics programs (or embedded device programs) interact directly with the Web layer or the EJB layer
Web layer: Running servlet/jsp
EJB layer: Run EJB, complete business logic operation
DB layer: Back-end database, providing data access services to Java programs

4. Java Embedded Application
Java embedded applications are a burgeoning area, engaged in embedded development, need to download the J2ME development package from the Sun, J2ME contains the embedded device dedicated virtual machine KVM, and the common JDK included in the JVM is different. There is also a need to download the simulator to a specific embedded vendor.


Java Learning Path (ii), book articles

To learn a new knowledge cannot be expected to read only one book, or two books can be fully mastered. There needs to be a step-by-step reading process. I recommend the OReilly published Java series books.

Here I just want to add that a lot of people learn Java from the book "Thinking in Java", but I think this book is not for beginners. I think the correct way to use this book should be as a supplementary reading. "Thinking in Java" is not a complete introduction of the entire system of Java, but a jump-style writing method, is a similar tips to the Java Many knowledge points for in-depth analysis and interpretation.

For beginners, it is best to find a book to get started in Java, but more complete and sequential introduction of Java syntax, object-oriented features, core class library and so on, while reading this book, you can sync to see "Thinking in Java", to deepen the understanding of Java and the use of the principle, At the same time you can fully understand the entire system of Java.

For a Java primer, Cai recommends OReilly's "Exploring Java, 2nd Edition" or "Java in a nutshell,2nd Edition (for C + + background)", and I have not read these two books. In fact, I think the electronic industry publishing house "Java 2 programming detailed" or "Java 2 from the introduction to proficient" is very good.

Of all the Java books, the most useful is not O ' Reilly's Java serials, but the most useful is the JDK's documentation! Almost all of the knowledge you want to get in the documentation is all there, the most important part of course is the Java Basic Class Library API documentation, is organized according to package, for each class has a detailed explanation, its inheritance relationship, whether the implementation of an interface, In what situations, it is also possible to find out all of its public properties and methods, the interpretation of each attribute, the purpose of each method, the invocation parameters, the meaning of the parameter, the type of the return value, and the exceptions that the method might throw, and so on. In this way, all the books on Java programming are simply introducing the use of some of the classes contained within a package in documentation, in a more comprehensible language, and in a well-organized way. So same, if you have enough power to learn Java libraries directly through documentation, then basically you don't need to look at other books. In addition, documentation is also a prerequisite for programming manuals, my desktop has three documentation shortcuts, The documentation of the documentation and j2sdkee1.3.1 of the documentation,servlet2.3 of j2sdk1.4.1 are respectively. With this three documentation, no other books are needed.

For Java WEB Programming, the core is to familiarize yourself with the HTTP protocol, which is not related to Java, after familiar with the HTTP protocol, you need to familiarize yourself with the Java implementation of the HTTP protocol class library, that is, the servlet API, so the most important thing is the servlet Api. Of course, for beginners, it's very difficult to learn web programming directly through the Servlet API, and I recommend O ' Reilly's Java Server Pages book to learn about Web programming.

EJB books, "Enterprise JavaBeans, 2nd Edition" is a very good book, EJB learning threshold is relatively high, difficult to get started, but this book completely reduced the difficulty of learning, particularly important point is that EJB learning needs to combine a kind of app Server, so while learning EJB, you must learn some kind of app Server synchronously, and this book is related to three books, respectively, weblogic6.1,websphere4.0 and JBoss3.0 The example of the deployment of the implementation. It's both theory and practice. As you learn about EJBS, you can do it while you look at it, and EJB learning becomes easier.

But the book also has a problem, is the version of the older, mainly speaking EJB1.1 norms and some EJB2.0 norms. and Ed Roman wrote "Mastering EJB 2.0" This book is written in accordance with the EJB2.0 specification, in simple language, covering all aspects of EJB programming, and there are many programming experience tips, is also learning EJB is very recommended by one of the books.

If it is a combination of Weblogic to learn Java EE, "Java application and Bea Weblogic Server" is definitely the first choice of reading, although it is the Weblogic6.0, still worth buying, this book is an official recommendation of Bea, the author is also the engineer of BEA company. Now the Chinese version is everywhere. This book combined with WebLogic introduced all aspects of Java EE Technology in the WebLogic platform development and deployment, practical guidance of a very strong significance.

After mastering the basics of Java platform and the knowledge of EE, the further is to learn how to use Oo method to design software, then you must learn "design mode." Sun has published a "Java EE core model", which is a must-have book for every architect who develops the software for the Java-based Enterprise platform. This book comprehensively introduced the Java EE architecture of various design patterns, is the designer must read books.

Java Learning Path (iii) process Chapter

Everyone's learning methods are different, one person's method is not suitable for another person, I can only talk about their own learning methods. Because I study Java is completely self-study, never asked someone else, so the process of learning is basically completely groping themselves out. I do not know whether this method is a better method, can only provide a point of reference for everyone.

The first step in learning Java is to install the JDK, write a Hello World, in fact JDK learning is not so simple, there are two problems with the JDK is easy to always haunt the Java programmers Place: One is the classpath problem, in fact, in principle, is to figure out how the ClassLoader of the JRE load class, and another problem is the package and import issues, and how to find the path problem of the class. By finding out the two issues, the biggest obstacle to learning Java and using JDK is clear. It is recommended to take a look at Sen Wang's "Java Depth Adventures" to discuss these two issues in depth.

The second step is to learn Java syntax. Java syntax is a class C + +, basically the mainstream programming language is not the class of the CS, is the type C + +, there is nothing new, so the grammar of the study, probably half a half-day time enough. The only thing to be aware of is that there are a few difficult to figure out the use of keywords, public,protected,private,static, when to use, why to use, how to use, this may need someone to point out, I was completely myself figured out, spent a long time. But then I saw the book "Thinking in Java", which read these concepts.

The third step is to learn the characteristics of Java object-oriented programming languages. such as inheritance, constructors, abstract classes, interfaces, polymorphism of methods, overloads, Overrides, Java exception handling mechanisms. For a person who doesn't have an object-oriented language background, I think this process will take a long time, because learning Java before the experience of C + +, only the experience of C, I was about to spend about one months or so, only to thoroughly understand these concepts, the book above the example repeatedly try to figure out, modify, attempt, The contents of those chapters repeatedly look over, look at the past, see more than 5 times, only to thoroughly comprehend. But I think if you have C + + experience, it should be a two-day time enough. So in this process, you can take a look at the book "Thinking in Java", the object-oriented explanation is very thorough. Unfortunately, when I study, and did not see this book, so I spent a lot of time, through their own attempts and try to learn.

The fourth step is to start familiar with Java class libraries. Java's base Class library is actually Jre\lib\rt.jar this package under the JDK installation directory. Learning the Basic class library is learning Rt.jar. There are very many classes inside the base Class library. It is said that there are more than 3,000, I do not have statistics. But the real core for us is only 4, respectively
java.lang.*;
java.io.*;
java.util.*;
java.sql.*;

This four-pack study, each bag of learning can be written as a thick textbook, and O ' Reilly did do so. I think if time is tight, it is impossible to learn by reading four books. I think the better way to learn is this:
The first step is to read through the entire package framework, to understand the composition of the entire package class,interface,exception, preferably to find articles that introduce the entire package framework. The first chapters of these books that specialize in packages should be an introduction to these overall framework content.

The overall framework of the package is not to familiarize yourself with the usage of each class, to remember what attributes it has, and how. I can't remember it. It's about knowing what the package has to do with the classes, what these classes are for, and how many of the core classes are done. When I give people training, I usually talk about a bag in class. So it is not possible to describe the use of each class in detail, but I repeat that I am telling you these packages not to tell you how the class method is invoked, nor do you want to remember the method calls of the class, but rather you understand what Java provides us with the classes, where each class is used, when I encounter a problem, I know which class, or the combination of the classes, can solve my problem, that ' all! , when we specifically write the program, as long as you know which class to use to complete your work is enough. When coding, the specific method call, is the side writes the code, the side checks documentation, all things are inside the documentation, does not require you must remember, actually you also can not remember 3,000 multiple class's altogether nearly 100,000 method calls. Therefore, the overall framework of each package to grasp the importance of becoming extremely important.

The fifth step, through the above study, if the study of a more solid, then lay the foundation of Java, the rest to do is to clear the documentation inside in addition to the above 4 packets of some other more useful classes. Believe that progress to this step, the ability to self-study of Java has been cultivated, can be directly to learn the level of documentation. In addition to GUI programming, other useful packages in the JDK are these:
java.text.*;
java.net.*;
javax.naming.*;
These bags really use more of the class is actually very few, only a few, so do not need to spend a lot of time.

Step sixth, Java Web programming
The core of Web programming is the HTTP protocol, HTTP protocol and Java-independent, if not familiar with the HTTP protocol, although also can learn servlet/jsp programming, but not to extrapolate, Itong realm. So the study of HTTP protocol is necessary. If you are familiar with the HTTP protocol, and have a good foundation for Java programming, Learning servlet/jsp is simply easy, I learn servlet/jsp used less than a week, and then began to use JSP to do the project.

In Servlet/jsp's study, the documentation is still the servlet. The Servlet API has few classes that are most commonly used, and it takes less time to master. Look over these classes and write a few more examples to try. The essence of servlet/jsp programming is to call these classes over and over again to communicate between the Web server and brower through the HTTP protocol. In addition to JSP, but also need to be familiar with several common JSP tags, the specific wording of the words, temporary check just.

In addition, Java Web Programming learning focus on the Web application design mode, how to conduct business logic analysis, and reasonable design, according to the MVC design pattern requirements, using servlet and JSP to complete different logic layer, Learn how to control and share data between the servlet and the JSP, and how the Web application should be configured and deployed.

Seventh step, Java EE programming
The above learning process if it is relatively smooth, to this step, difficulty and suddenly improve. Because the above knowledge content is only involved in one aspect, and such as EJB,JMS,JTA, such as the core of the Java EE specification is often a combination of the use of a number of techniques of the crystallization, so it is difficult to master the larger.

First of all, we must learn good Jndi,jndi is the app Server Locator Server resource (EJB component, DATASOUCE,JMS) lookup method, if not familiar with Jndi, ejb,jms these things can hardly learn. Jndi is actually javax.naming.* this bag, it is very simple to use. The difficulty is in configuring the server resource files. For the server resource file configuration, you need to look at the specific documentation specifications, such as Web.xml, Ejb-jar.xml, and so on. For each of the different app servers, there are also their own service resource profiles that need to be familiar.

You can then learn JTA, mainly to understand JTA's approach to the control of the transaction, and where to use JTA. As a simple example, we know that the general situation can be transaction control for a database connection (Conn.setautocommit (false),...., Conn.commit ()) as an atomic operation, But suppose my business requirement is to make the operation of two different databases an atomic operation, can you do it? At this time can only use JTA. Suppose the procedure is to insert a record into a database, then delete the B database another record, we write the code can not control the whole operation as an atomic operation. With JTA, the app server is the way to complete the control.

Learning about object serialization and Rmi,rmi is the basis of EJB before learning EJB. Then, to learn about JMS and EJB, the key to EJB is to understand how EJBS implement calls to remote objects through RMI, and under what circumstances EJB is used.

After learning ejb,jms These things, you may be aware of the impatience to learn two areas of knowledge, one is UML, the other is design pattern. Java enterprise Software Design attaches great importance to the framework of the design, a good software framework is the prerequisite for the success of software development. At this time, should begin to focus on the study of design patterns and framework of learning, through learning and practical programming experience to master the EJB design pattern and Java EE core model.

Java-ee norms inside, in addition to EJB,JMS,JTA,SERVLET/JSP,JDBC, there are a lot of enterprise technology, here is not one of the introduction.

There is also a new domain Web Services. Web Services doesn't have anything new at all, it's like a binder that can unify different services to provide a unified calling interface, and as a user, I just get the WSDL (the description of the service) given to me by the service provider, and that's enough, I have no idea whether the service provided by the server provider is an EJB component, or. NET component, or what CORBA component is, or what other implementations, I don't need to know. The greatest part of WEB services is the sharing of Internet services across the world through a unified approach to service delivery and invocation, which is a very exciting technical area. WEB services do not seem to have any good books at the moment, but they can be learned by looking up information on the web.

Java Learning Path (iv) method chapter

Java as a programming language, the best way to learn is to write code. When you learn a class, you can write a simple example of the program to run it, see what the results, and then call several classes of methods to see the results of the operation, so very intuitive to learn the class, and memory is very profound. Then you should not be satisfied with the code, you should think about it if I do not write, another way, try again. Remember which high man said learning programming is a destructive process, the book example, their own learning documentation written examples in the running through, and constantly try to use different methods to achieve, and constantly try to destroy the structure of the code, to see what it will result. In this way, you will be thoroughly proficient in mastering Java.

For example, we've all 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 define public static void main (string[] args), can you not write this? Even when I was learning Java, I had this kind of question. You want to know the answer? Very simply, you change the name of main to run, look at what the report error, and then based on the error information analysis; Take the main public off, in a try, report what error, static remove still can not run, do not know whether the main method must pass a string[] array, String[] Change to int[], or string to try, do not know whether to write the args parameter name, you can change the args to another name to see how the results of the operation.

That's what I did when I was learning Java, changing the Hello World program seven or eight times, running, analyzing the results, and finally knowing why the main method was defined.

In addition, I was not very understanding of staic,public,private,exception,try{}catch {}finally{}, and so on and so on, all of them are the example of the reference books to run successfully, and then began to destroy it, Constantly according to their own heart in the doubt to rewrite the program to see if it can run, run out what it looks like, whether can get the expected results. This may be time-consuming, but an example of a program that repeatedly destroys after several times. I have learned the relevant knowledge thoroughly. Sometimes even deliberately write some wrong code to run to see if you can get the expected run error. So the mastery of programming is profound.

Of particular note is the JDK has a very good debugging function,-verbose
Java–verbose
Javac–verbose and many other JDK tools have this option
-verbose can show where the JVM is loading the class in turn during command execution, which helps us analyze what the JVM is doing during execution.

In addition, in the learning process, write a lot of this destruction routines, should be aware of the categorization of the preservation, in the work of the accumulation of typical routines should also be regularly sorted, accumulated over time, they have a code base. Encounter similar problems, to the code library inside Copy & Paste, Search & Replace, just fine, greatly improve the development speed. The ideal scenario is to abstract some common routines into one layer, forming a common class library, packaged. Then the reusability is even stronger.

So I think it is not particularly necessary routines, their own written destruction routines is the best example, if you really do not trust yourself to write the code, I strongly recommend you look at the JDK base Class library Java source code. Under the JDK installation directory there will be a src.zip, you can unlock the entire JDK base Class library, that is, Rt.jar Java source code, you can refer to sun is how to write Java program, what the specification is like. I am learning Java class Library, when some places do not understand very clearly, or want to more clearly understand the operation of the details of the time, often open the corresponding class source code, by looking at the source code, all the problems will dispelled.

Java Learning Path (v) Resource article

1, http://java.sun.com/(English)
Sun's Java Web site is a place that should be seen often. Don't say much.

2, http://www-900.ibm.com/developerWorks/cn/
IBM's Developerworks website, English good direct to the English main site to see. This is not only an excellent object-oriented analysis design site, but also a very good web site Services,java,linux. Highly RECOMMENDED!!!

3, http://www.javaworld.com/(English)
Discussion and news about many new technologies in Java. To learn more about Java's applications, here is better.

4, http://dev2dev.bea.com.cn/index.jsp
Bea's developer corner, Bea, as the most important app server vendor, has a lot of unique technology, and the development of WebLogic friends should not be missed.

5, http://www.huihoo.com/
Gray Fox Power website, a professional middleware site, although not a professional Java site, but in the application technology of EE enterprises have deep attainments.

6, http://www.theserverside.com/home/(English)
Theserverside is a well-known web site specifically for Java server-side applications.

7, http://www.javaresearch.org/
Java Research Organization, there are many excellent Java aspects of the articles and tutorials, especially in the jdo aspect of the article is more rich.

8, http://www.cnjsp.org/
JSP technology website, there are quite a lot of Java aspects of the articles and resources.

9, http://www.jdon.com/
Jdon Forum, is a personal character of the Chinese Java Java Professional Technical Forum, in many of the Chinese Language Forum, Jdon is a very high technical content, post quality is very good forum.

10, http://sourceforge.net/
Sourgeforge is a stronghold of open source software, which also has very, very rich Java open source well-known 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.