(1) Tools
1. 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, it essentially has a certain version of JDK built-in. Therefore, mastering JDK is the first step to learn Java well. The most mainstream 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, Jrocket by BEA, and JDK developed by the GNU organization, etc. . The JVM (Java Virtual Machine) included in IBM's JDK runs much more efficiently than the JVM included in Sun JDK. Jrocket, which specifically runs on the x86 platform, is much more efficient on the server side than Sun JDK. But no matter what, we still need to master Sun JDK first.
1. Download and install JDK
JDK is also called J2SE (Java2 SDK Standard Edition). It can be downloaded from Sun's Java website, http://java.sun.com/j2se/downloads.html . The latest version of JDK is J2SDK1.4.2. It is recommended to download this version of JDK, the download page is here: http://java.sun.com/j2se/1.4.2/download.html .
The downloaded JDK is an executable installation program. After the default installation, a set of JRE (for browser use) will be installed in the C:Program FilesJava directory, and a set will be installed in C:j2sdk1.4.2 JDK (also includes a set of JRE). Then we need to add the java path C:j2sdk1.4.2bin at the front of the environment variable PATH. The JDK is now installed.
2. JDK command tool
The most important command line tools of the JDK:
java: Start JVM to execute class
javac: Java compiler
jar: Java packaging tool
javadoc: You must be very, very familiar with the command lines of the Java documentation generator and be proficient in each parameter. For learning these commands, there are detailed documents on the JDK Documentation.
2. JDK Documentation
Documentation also has a download link on the JDK download page. It is recommended to 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 when learning Java programming, most of the time is spent reading this Documentation. I carry it with me. When writing Java code, I can check it at any time and never leave it.
3. Application Server (App Server)
App Server is a platform for running Java enterprise components and constitutes the main operating environment of application software. The current mainstream App Servers are BEA's Weblogic Server, IBM's Websphere and the free Jboss. Just choose one of them to learn. I personally recommend Weblogic because its architecture is cleaner and development and deployment are more convenient. It is Java The development platform of choice for enterprise software developers. The following is a brief introduction to several commonly used App Servers:
1. Tomcat
Tomcat is not a real App Server in the strict sense. It is just a Web container that can support running Serlvet/JSP. However, Tomcat also extends some App Server functions, such as JNDI, database connection pool, user transaction processing, etc. Tomcat is widely used in small and medium-sized Java Web applications, so this article will give an introduction to downloading, installing and configuring Tomcat:
Tomcat is a sub-project of the Jakarta project under the Apache organization. Its main website is: http://jakarta.apache.org/tomcat/ . The latest version of Tomcat is Tomcat4.1.27. The link for software download is: http:// www.apache.org/dist/jakarta/tomcat-4/binaries/ .
To download Tomcat, you can either download the zip package directly or download the exe installation package (I personally recommend zip to be cleaner). In either case, after downloading and installing (just decompress the zip directly). 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 and run CATALINA_HOMEbinstartup.bat. Close Tomcat and run the shutdown.bat script. After Tomcat starts, port 8080 is used by default, so you can use a browser to access http://localhost:8080 to test whether Tomcat starts normally.
Tomcat provides two web interface management tools, the URLs are:
http://localhost:8080/admin/index.jsp
http://localhost:8080/manager/html
Before enabling these two management tools, you need to manually configure the administrator user and password. Use a text tool to open the file CATALINA_HOMEconftomcat-users.xml and add the following lines:
<role rolename="manager"/>
<role rolename="admin"/>
<user username="robbin" password="12345678" roles="admin,manager,tomcat"/>
In this way, the user "robbin" has super administrator privileges. After restarting Tomcat, you can use this user to log in to the two management tools above and configure and manage Tomcat through the Web.
2. BEA Weblogic
Weblogic can be registered for free on BEA's website and then downloaded the latest Weblogic8.1 enterprise version. The license can be used for free for one year. In fact, this is completely enough. Weblogic download link: http://commerce.bea.com/index.jsp , Weblogic online documentation: http://edocs.bea.com/ .
3. IBM WebSphere
Websphere can also be downloaded as a free trial version. You can see the download of Websphere trial products and related Websphere information on IBM's developerWorks website. The link to the developerWorks Chinese website is: http://www-900.ibm.com/developerWorks /cn/wsdd/ , Websphere download link: http://www7b.software.ibm.com/wsdd/downloads/WASsupport.html .
4. Jboss
Jboss is a free and open source App Server, which can be downloaded for free from the Jboss website: http://www.jboss.org/index.html . However, the Jboss documentation is not free and requires money to purchase, so it is set up for us to learn Jboss. certain obstacles. There are several good Jboss configuration documents on Jdon that you can use for reference: http://www.jdon.com/idea.html
4. Running environment of Java applications
Java applications can be simply divided into the following aspects:
1. Java desktop applications Desktop applications generally only require the support of JRE.
2. Java Web Application
A Java web application requires at least the installation of JDK, a web container (such as Tomcat), and a multi-user database. The web application is divided into at least three layers:
Browser layer: The browser displays the user page
Web layer: running Servlet/JSP
DB layer: back-end database, providing data access services to Java programs
3. Java enterprise-level applications Enterprise-level applications are relatively complex and can be extended to n layers. In the simplest case, they will be divided into 4 layers:
Browser layer: The browser displays the user page
Client layer: Java client graphics program (or embedded device program) directly interacts with the Web layer or EJB layer
Web layer: running Servlet/JSP
EJB layer: run EJB and complete business logic operations
DB layer: back-end database, providing data access services to Java programs
4. Java embedded applications
Java embedded applications are an emerging field. To engage in embedded development, you need to download the J2ME development package from Sun. J2ME includes a dedicated virtual machine KVM for embedded devices, which is different from the JVM included in the ordinary JDK. In addition, you need to download the simulator from a specific embedded manufacturer.
Java Learning Path (2), books
When learning a new knowledge, you cannot expect to fully master it by reading only one or two books. A step-by-step reading process is required. I recommend the Java series of books published by Oreilly.
I just want to add some opinions here. Many people start learning Java from the book "Thinking in Java", but I think this book is not suitable for beginners. I think the correct way to use this book is as supplementary reading. "Thinking in Java" is not a complete introduction to the entire Java system, but a jumping writing method, a tips-like method to conduct in-depth analysis and explanation of many Java knowledge points.
For beginners, it is best to find an introductory book to Java, which provides a relatively complete and step-by-step introduction to Java's syntax, object-oriented features, core class libraries, etc. While reading this book, you can read it simultaneously Read "Thinking in Java" to deepen your understanding of Java and the application of principles, and at the same time, you can have a complete understanding of the entire Java system.
For introductory books on Java, Cai Xueyong recommends "Exploring Java, 2nd Edition" or "Java in a Nutshell, 2nd Edition (for C++ background)" by Oreilly. I have not read these two books. In fact, I think "Java 2 Programming Detailed Explanation" or "Java 2 From Beginner to Master" by Electronic Industry Press are very good.
Among all Java books, the most useful one is not O'reilly's Java Serials, but the JDK's Documentation! Almost all the knowledge you want to obtain is available in Documentation. The most important part is of course the API documentation of the Java basic class library, which is organized according to packages. Each class has a detailed explanation and its inheritance. relationship, whether an interface is implemented, and in which situations it is usually used. You can also check all its public attributes and methods, the explanation and meaning of each attribute, the purpose of each method, the parameters of the call, and the meaning of the parameters. The type of return value, the exceptions that the method may throw, etc. It can be said that all books on Java programming are actually just using relatively easy-to-understand language and good organization to introduce the usage of some classes contained in a package in the Documentation. So everything remains the same. If you have enough ability to learn Java class libraries directly through Documentation, then basically there is no need to read other books. In addition, Documentation is also a necessary manual for programming. There are three Documentation shortcuts on my desktop, namely Documentation of J2SDK1.4.1, Documentation of Servlet2.3 and Documentation of J2SDKEE1.3.1. With these three Documents, no other books are needed.
For Java Web programming, the most important thing is to be familiar with and master the HTTP protocol. This has nothing to do with Java. After you are familiar with the HTTP protocol, you need to be familiar with Java's class library that implements the HTTP protocol, which is the Servlet API, so it is best to The important thing is the Servlet API. Of course, for beginners, it is very difficult to learn Web programming directly through Servlet API. I recommend O'reilly's "Java Server Pages" book to learn Web programming.
Among EJB books, "Enterprise JavaBeans, 2nd Edition" is a very good book. The learning threshold of EJB is relatively high and it is difficult to get started. However, this book completely reduces the difficulty of learning. The most important thing is that EJB The learning needs to be combined with the specific implementation of an App Server, so while learning EJB, you must also learn a certain App Server simultaneously. There are three books related to this book, namely Weblogic6.1, Websphere4.0 and Implementation of examples in the book deployed on JBoss3.0. It really has both theory and practice. While learning EJB, you can watch and do it at the same time, and learning EJB will become very easy.
But this book also has a problem, that is, the version is relatively old, and it mainly talks about EJB1.1 specifications and some EJB2.0 specifications. The book "Mastering EJB 2.0" written by Ed Roman is completely based on the EJB2.0 specification. It explains everything in simple terms and covers all aspects of EJB programming. It also has many programming experience tips. It is also one of the highly recommended books for learning EJB. .
If you are learning J2EE in conjunction with Weblogic, "J2EE Applications and BEA Weblogic Server" is definitely your first choice. Although it is about Weblogic 6.0, it is still worth buying. This book is an officially recommended textbook by BEA, and the author is also an engineer at BEA. . The Chinese version is now available everywhere. This book combines Weblogic to introduce the development and deployment of various aspects of J2EE technology on the Weblogic platform. It has very strong practical guidance significance.
After mastering the basic knowledge of the Java platform and J2EE, the next step is to learn how to use OO methods to design software, then you must learn "design patterns". Sun has published a book called "J2EE Core Patterns", which is a must-have book for every architect who develops Java enterprise platform software. This book comprehensively introduces various design patterns of J2EE architecture and is a must-read for designers.
Java Learning Path (3) Process
Everyone's learning method is different. One person's method may not be suitable for another person. I can only talk about my own learning method. Because I learned Java completely by myself and never asked anyone else, so the learning process was basically completely figured out by myself. I don't know if this method is a better method, I can only provide you with some reference.
The first step to learn Java is to install JDK and write a Hello World. In fact, learning JDK is not that simple. There are two problems about JDK that easily trouble Java programmers: one is the CLASSPATH problem. In fact, in principle, we need to figure out how JRE's ClassLoader loads Class; another problem is the package and import problem, and how to find the path of the class. Once these two issues are clarified, the biggest obstacle to learning Java and using JDK will be removed. It is recommended to read Wang Sen's "Java Deep Adventure", which has an in-depth discussion on these two issues.
The second step is to learn Java's syntax. Java's syntax is C++-like. Basically, mainstream programming languages are either C-like or C++-like. There is nothing new, so half a day is enough to learn the syntax. The only thing that needs attention is that there are several keywords that are not easy to understand, such as public, protected, private, static, when to use them, why to use them, and how to use them. This may require someone to give you some advice. I was completely on my own at the time. It took a long time to figure it out. But then I saw the book "Thinking in Java" which talks about these concepts.
The third step is where you learn the features of Java's object-oriented programming language. For example, inheritance, constructors, abstract classes, interfaces, method polymorphism, overloading, overriding, and Java's exception handling mechanism. For someone who has no object-oriented language background, I think this process takes a long, long time, because I have no experience in C++ before learning Java, only experience in C. It took me about a month or so to complete it. After clarifying all these concepts, I repeatedly pondered, revised, and tried the examples in the book. I read the contents of those chapters over and over again. I read them no less than 5 times before I fully understood them. But I think if you have C++ experience, one or two days should be enough. So during this process, you can read more about the book "Thinking in Java", which explains object-oriented very thoroughly. It's a pity that I didn't read this book when I was studying, so I spent a lot of time to learn it through my own trials and speculations.
The fourth step is to become familiar with Java's class library. The basic class library of Java is actually the jrelibrt.jar package under the JDK installation directory. Learning the basic class library is learning rt.jar. There are many, many classes in the basic class library. It is said that there are more than 3,000, but I have not counted them. But there are only 4 that are really core to us, namely
java.lang.*;
java.io.*;
java.util.*;
java.sql.*;
The study of these four packages can be written into a thick textbook, and O'reilly does this. I feel that if time is tight, it is impossible to learn by reading four books. I think a better way to learn is this:
First of all, you must read through the entire package framework and understand the composition of the entire package's classes, interfaces, and exceptions. It is best to find an article that introduces the entire package framework. The first few chapters of these books dedicated to packages should be an introduction to these general framework contents.
To grasp the overall framework of the package is not to be familiar with the usage of each class, but to remember what attributes and methods it has. I can't remember it even if I want to. Rather, you need to know what classes the package is composed of, what are the uses of these classes, and what functions are completed by the core classes. When I train people, I usually teach one package at a time, so it is impossible to introduce the usage of each class in detail, but I have repeatedly emphasized that I am not telling you about these packages to tell you how to call the class methods. , it does not require you to remember the method calls of the classes, but it requires you to understand what classes Java provides us, and when each class is used. When I encounter a problem, I know which class, or where A combination of several classes can solve my problem, That'all! , when we write a program specifically, it is enough as long as you know which class to use to complete your work. When coding, the specific method call is to check the Documentation while writing the code. Everything is in the Documentation. You are not required to remember it. In fact, you cannot remember a total of nearly 100,000 methods in more than 3,000 classes. call. Therefore, it becomes extremely important to grasp the overall framework of each package.
Step 5: Through the above study, if you have learned more solidly, you will have laid the foundation of Java. The remaining work to be done is to clear out some other useful packages in Documentation besides the above 4 packages. kind. I believe that at this point of progress, Java's self-learning ability has been developed, and it has reached the level of directly learning Documentation. In addition to GUI programming, other useful packages in the JDK are as follows:
java.text.*;
java.net.*;
javax.naming.*;
There are actually very few commonly used classes in these packages, only a few, so you don’t need to spend a lot of time.
Step Six, Java Web Programming
The core of Web programming is the HTTP protocol. The HTTP protocol has nothing to do with Java. If you are not familiar with the HTTP protocol, you can learn Servlet/JSP programming well, but you will not be able to draw inferences from one example and understand everything. Therefore, learning the HTTP protocol is necessary. If you are familiar with the HTTP protocol and have a good foundation in Java programming, learning Servlet/JSP is easy. It took me less than a week to learn Servlet/JSP, and then I started using JSP to do projects.
In the study of Servlet/JSP, the most important thing is still Servlet Documentation. There are very few most commonly used classes in the Servlet API, and you can master them in relatively little time. Read through these categories and try writing a few more examples. The essence of Servlet/JSP programming is to repeatedly call these classes to talk between the Web Server and the Brower through the HTTP protocol. In addition, for JSP, you need to be familiar with several commonly used JSP tags. If you can't remember the specific writing method, you can just look it up temporarily.
In addition, the focus of Java Web programming learning should be on the design pattern of Web Application, how to analyze business logic and carry out reasonable design. According to the requirements of MVC design pattern, use Servlet and JSP to complete different logic layers respectively, and master how to Process control and data sharing between Servlet and JSP, as well as how Web Application should be configured and deployed.
Step 7: If the learning process of J2EE programming and above is relatively smooth, the difficulty will suddenly increase at this step. Because the above knowledge content 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, they are relatively difficult to master.
First of all, you must learn JNDI well. JNDI is the App Server location server resource (EJB component, Datasouce, JMS) search method. If you are not familiar with JNDI, it is almost impossible to learn EJB and JMS. JNDI is actually the javax.naming.* package, which is very simple to use. The difficulty lies in the configuration of server resource files. For the configuration of server resource files, you need to look at special document specifications, such as how to write web.xml, how to write ejb-jar.xml, etc. For each different App Server, there is also its own service resource configuration file, which you also need to be familiar with.
Then you can learn JTA, mainly to understand how JTA controls transactions and when to use JTA. Here is a simple example. We know that generally we can perform transaction control on a database connection (conn.setAutoCommit(false),....,conn.commit()) as an atomic operation, but suppose that my The business requirement is to perform operations on two different databases as an atomic operation. Can you do it? At this time, JTA can only be used. Assume that the operation process is to first insert a record into database A, and then delete another record from database B. If we write the code ourselves, we cannot control the entire operation as an atomic operation. With JTA, control is completed by the App Server.
Before learning EJB, you must learn object serialization and RMI. RMI is the foundation of EJB. Next, learn JMS and EJB. For EJB, the most important thing is to understand how EJB implements calls to remote objects through RMI, and under what circumstances EJB is used.
After learning EJB and JMS, you may realize that you can't wait to learn knowledge in two areas, one is UML and the other is Design Pattern. The design of Java enterprise software attaches great importance to the design of the framework. A good software framework is a necessary condition for successful software development. At this time, you should start to focus on learning design patterns and frameworks, and master the design patterns of EJB and the core patterns of J2EE through learning and practical programming experience.
In the J2EE specification, in addition to EJB, JMS, JTA, Servlet/JSP, and JDBC, there are many, many enterprise technologies. I will not introduce them one by one here.
There is also a latest field, Web Services. Web Services does not have anything new at all. It is like a glue that can unify different services to provide a unified calling interface. As a user, I only need to obtain the WSDL given to me by the service provider (for the service description) is enough. I have no idea whether the service provided by the server provider is an EJB component, a .Net component, a CORBA component, or some other implementation, and I don't need to know. The greatest thing about Web Services is that it realizes the sharing of entire Internet services through unified service provision and calling methods. It is a very exciting technical field. It seems that there are no good books on Web Services yet, but you can learn about it by looking up information on the Internet.
Java Learning Path (4) Methods
As a programming language, the best way to learn Java is to write code. After you learn a class, you can write a simple example program and run it to see what the results are. Then call a few more class methods to see the running results. This way you can learn the class very intuitively. , and the memory is very profound. Then you should not be satisfied with adjusting the code. You should think about whether it would work if I didn't write it this way, try another way and try again. I remember an expert said that learning programming is a process of destruction. After running through the examples in the book and learning how to write Documentation, I kept trying to use different methods to achieve it, and kept trying to destroy the structure of the code. Take a look. What will be the result of it. In this way, you will master Java thoroughly and proficiently.
For example, we have all programmed Hello World
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Many beginners don't quite understand why the main method must be defined like this: public static void main(String[] args). Can it be written differently? Including when I first learned Java, I also had such questions. Want to know the answer? It's very simple. You can rename main and run it to see what errors are reported, and then analyze it based on the error message; remove the public from main and try it again to see what errors are reported; can it still run after removing static? I don't know if main Does the method have to pass a String[] array? Change String[] to int[], or try String. I don’t know if it is necessary to write the args parameter name. You can also change args to another name. See what the results are.
This is what I did when I first learned Java. I changed the Hello World program seven or eight times, kept running it, and analyzed the running results. Finally, I completely understood why the main method was defined this way.
In addition, I didn't know much about staic, public, private, Exception, try{}catch {}finally{}, etc. at the beginning. I just ran the examples in the reference book successfully, and then started to destroy them, constantly Rewrite the program based on your own questions to see if it can run, what it will look like when running, and whether you can get the expected results. Although this is more time-consuming, after a sample program is repeatedly destroyed in this way several times. I have thoroughly learned this related knowledge. Sometimes I even deliberately write some wrong code to run it to see if I can get the expected running error. This mastery of programming is extremely profound.
What is particularly worth mentioning is that JDK has a great debugging function, -verbose
java –verbose
javac –verbose and many other JDK tools have this option
-verbose can display which Class the JVM loads in sequence during the execution of the command. Through this valuable debugging information, it can help us analyze what the JVM did during the execution.
In addition, during the learning process, I wrote a lot of such destructive routines, and I should consciously save them in categories. The typical routines accumulated at work should also be organized regularly. Over time, I will have a code base. When encountering similar problems, just go to the code base to Copy & Paste, Search & Replace, which greatly improves the development speed. The most ideal situation is to abstract some common routines themselves to form a common class library and encapsulate them. Then the reusability will be stronger.
So I think routines are not particularly needed. The destruction routines written by yourself are the best example. If you are really worried about the code you wrote, I strongly recommend you to take a look at the Java source code of the JDK basic class library. There will be a src.zip under the JDK installation directory. After unzipping it, you can completely see the entire JDK basic class library, which is the Java source code of rt.jar. You can refer to how Sun writes Java programs and specifications. What does it look like. When I am learning the Java class library, when I don’t understand something very clearly, or when I want to understand the details of the operation more clearly, I often open the source code of the corresponding class. By looking at the source code, all problems will be wiped away.
Java Learning Path (5) Resources
1. http://java.sun.com/ (English)
Sun's Java website is a place that should be visited frequently. Needless to say.
2. http://www-900.ibm.com/developerWorks/cn/
IBM's developerWorks website, if you are good at English, go directly to the main 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. Highly recommended! ! !
3. http://www.javaworld.com/ (English)
Discussions and news about many new technologies in Java. If you want to know more about all aspects of Java applications, this is a better place.
4. http://dev2dev.bea.com.cn/index.jsp
BEA's Developer Forum. As the most important App Server manufacturer, BEA has many unique technologies. Friends who develop on Weblogic should not miss it.
5. http://www.huihoo.com/
Gray Fox Power website is a professional middleware website. Although it is not a professional Java website, it has profound attainments in J2EE enterprise application technology.
6. http://www.theserverside.com/home/ (English)
TheServerSide is a well-known website dedicated to Java Server-side applications.
7. http://www.javaresearch.org/
The Java Research Organization has many excellent articles and tutorials on Java, especially on JDO.
8. http://www.cnjsp.org/
The JSP technology website has quite a few articles and resources on Java.
9. http://www.jdon.com/
Jdon Forum is a personal Chinese J2EE professional technical forum. Among the many Chinese Java forums, Jdon is a forum with very high technical content and very good quality of posts.