Java learning from getting started

xiaoxiao2021-03-06  88

Java learning from getting started - Old version [Repost]

Author: robbin (MSN: robbin_fan AT hotmail DOT com)

Java Learning Path (1), Tools

First, JAVA Development Kit)

JDK is the core of the entire Java, including Java Runtime Envir, a bunch of Java Tools, and Java-based class libraries (RT.jar). Regardless of the Java application server, it is built into a version of JDK. So master JDK is the first step in learning Java. The mainstream JDK is the JDK released by Sun. In addition to Sun, many companies and organizations have developed their JDK, such as the JDKTed by IBM, BEA's JROCKET, as well as GNU organizations, etc. . The JVM (Java Virtual Machine) of the IBM's JDK is much higher than the JVM contained in Sun JDK. Jrockets running in the X86 platform are also much better than Sun JDK in the X86 platform. But no matter what, we still need to master Sun JDK first.

1, JDK download and installation

JDK is also known as J2SE (Java2 SDK Standard Edition), you can download from Sun's Java website, http: //java.sun.com/j2se/downloads.html, JDK current latest version is J2SDK1.4.2, it is recommended to download it Version JDK, download page here: http://java.sun.com/j2se/1.4.2/download.html.

Downloading JDK is an executable installer, the default installation will be installed in the C: / Program files / java / directory, install a set under C: /J2SDK1.4.2 JDK (also included a set of JRE). Then we need to increase Java path C: /J2SDK1.4.2/bin at the forefront of the environment variable Path. This way, JDK is installed.

2, JDK command tool

JDK's most important command line tool:

Java: Start JVM to perform CLASS

Javac: Java compiler

JAR: Java Packing Tool

Javadoc: Java Document Builder

These command lines must be very familiar, and they must be very proficient in each parameter. For these commands, there is a detailed documentation on the JDK Documentation.

Second, JDK Documentation

Documentation also has downloaded connections in the JDK download page, which is recommended to download the Documentation at the same time. Documentation is the most important programming manual covers the description of all Java all aspects. It can be said that learning Java programming, most of the time is watching this documentation. I am carrying it with you, when I write Java code, I will see it at any time.

Third, the application server (App Server)

App Server is a platform running Java Enterprise Components that forms the main operating environment of the application. The current mainstream App Server is a WebLogic Server and IBM's WebSphere and free JBOS, and one of them can be learned. Personally recommend WebLogic, because it is more convenient, developed and deployed, is Java Enterprise software developers preferred development platform. Believe in a brief introduction to several common App Server: 1, Tomcat

Tomcat is not a real app server, it is just a web container that supports running Servervet / JSP, but Tomcat has also extended some App Server features such as JNDI, database connection pool, user transaction, and more. Tomcat is very widely used in small and medium-sized Java web applications, so this article does a little download, install, and configure Tomcat introduction:

Tomcat is a sub-project under the Jakarta project under 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/.

Download Tomcat can download the ZIP package directly, you can also download the EXE installation package (personal suggestion zip cleaner), no matter which case, after downloading (ZIP direct decompression). Need to set two environment variables:

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, close Tomcat running shutdown.bat scripts. After Tomcat starts, the 8080 port is used by default, so you can use your browser to access http: // localhost: 8080 to test whether Tomcat is started normally.

Tomcat provides two management tools for two web interfaces, and the URLs are:

Http: // localhost: 8080 / admin / index.jsp.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 Catalina_home / conf / tomcat-user.xml, add the following line:

This user "Robbin" has super administrator privileges. After restarting Tomcat, you can use the user to log in to the above two management tools, and perform Tomcat configuration and manage through the web mode.

2, Bea WebLogic

WebLogic can be downloaded to the latest WebLogic8.1 Enterprise Edition after free on the BEA website, and License can use for free for free, in fact, this is fully enough. WebLogic download: http://commerce.bea.com/index.jsp, webLogic's online document: http://edocs.bea.com/. 3, IBM WebShpere

WebSphere can also be downloaded to the free trial version, to the IBM's developerWorks website, you can see the download and related WebSphere's data for WebSphere trial products, the connection of WebSphere, the connection: http://www-900.ibm.com/developerWorks / CN / WSDD /, WebSphere download: http://www7b.software.ibm.com/wsdd/downloads/wassupport.html.

4, JBoss

JBoss is a free open source App Server, you can download free from JBoss website: http://www.jboss.org/index.html, however JBoss's document is not free, you need to spend money, so learn JBoss settings for us. A certain obstacle. There are a few good JBoss configuration documents on JDON, which can be used for reference: http://www.jdon.com/idea.html

Fourth, Java application operating environment

Java applications can be divided into the following aspects:

1, Java desktop application

Desktop applications generally only need JRE support is sufficient.

2, Java web application

Java's web application requires at least JDK and a web container (such as Tomcat), and a multi-user database, the web application is at least three layers:

Browser layer: browser displays user page

Web layer: Run servlet / jsp

DB layer: backend database provides data access services to Java programs

3, Java enterprise application

Enterprise applications are more complicated, can be extended to N layers, the simplest situation will be divided into 4 layers:

Browser layer: browser displays user page

Client layer: Java client graphics (or programs for embedded devices) interact with Web or EJB

Web layer: Run servlet / jsp

EJB layer: Run EJB, complete business logic

DB layer: backend database provides data access services to Java programs

4, Java embedded application

Java embedded applications are the field of unreasonable, engage in embedded development, need to download J2ME development kits from Sun, J2ME contains embedded device-specific virtual machine KVM, and the JVM contained in the normal JDK is different. It also needs to download the simulator to a specific embedded vendor.

Java Learning Path (2), books

Learn a new knowledge, it is impossible to expect only one thing, or two books can be fully grasp. Need to have a step-by-step reading process. I recommend Oreilly published Java series books.

Here I only want to add a point, many people learn Java, starting from "Thinking In Java", but I think this book is not suitable for beginners. I think the correct use of this book should be an auxiliary reading. "Thinking in Java" is not a complete introduction to Java's entire system, but a jumping writing method, a method similar to TIPS to analyze and explain a lot of Java's knowledge points.

For beginners, it is best to find a book of Java entry, but more complete steps introduced Java grammar, object-oriented features, core class libraries, etc., while seeing this book, you can synchronize Look at "Thinking in Java" to deepen the use of Java's understanding and principles, while you can completely understand the entire system of Java. For Java's entry books, Cai Xueqi recommended is Oreilly's "Exploring Java, 2nd Edition" or "Java in A Nutshell, 2nd Edition", I haven't seen these two books. In fact, I think the "Java 2 programming detailed explanation" or "Java 2 to be proficient" is very good.

Among all Java books, it is most useful, not O'Reilly Java Serials, the most most useful place is the JDK Documentation! Almost all the knowledge you want is all in the documentation, the most important part of which is of course the API document of the Java underlying class library, which is organized according to Package, which has a detailed explanation for each Class, its inheritance Relationship, whether to implement an interface, which occasions are usually used, and you can find all the properties and methods of all the publications, the interpretation, meaning, the purpose of each attribute, the use of the parameters, the meaning of the parameters, The type of return value, and the exception that may be thrown. It can be said that all books in Java programming are actually in the use of more popular, easy-to-understand language, and good organizational methods to introduce some of the use of some classes contained in the Documentation in the documentation. Therefore, you will not leave the Zong. If you have enough ability to learn Java's class libraries through Documentation, then you don't need to see other books. In addition, Documentation is also a must-have manual, and there is three Documentation shortcuts on my desktop, respectively, Documentation, servlet2.3 Documentation, and J2SDKee1.3.1, respectively. Documentation. With this three documentation, what other books are not needed.

For Java Web programming, the core is to be familiar with and master the HTTP protocol. This is not related to Java. After familiar with the HTTP protocol, you need to be familiar with Java's implementation HTTP protocol, which is the servlet API, so the most The important thing is the servlet API. Of course, for beginners, there is a big difficulty through the servlet API to learn Web programming, I recommend O'Reilly's "Java Server Pages" book to learn Web programming.

In the book of EJB, "Enterprise Java Beans ?, 2nd Edition" is a very good book, EJB's learning threshold is relatively high, it is difficult to get started, but this book completely reduces the difficulty of learning, especially important EJB learning needs to combine a specific implementation of App Server, so while learning EJB, you must learn some kind of App Server, and this book is related to WebLogic 6.1, WebSphere4. 0 and JBoss3.0 Examples of the examples of the above deployment. It is really theoretical and practical. While learning EJB, you can do it while you can do it, and EJB learning will become easier. But this book also has a problem, which is the old version, mainly talking about EJB1.1 norms and some EJB2.0 specification. The book written by ED Roman is completely written according to EJB2.0 specification, in-depth light, covering all aspects of EJB programming, and many programming experience Tips, is also one of the books that study EJB very recommended .

If you are learning J2EE in conjunction with WebLogic, "J2EE Application and Bea WebLogic Server" is definitely the first choice, although it is a description of WebLogic6.0, it is still worth buying. This book is a BEA officially recommended textbook. The author is a engineer of BEA. . The Chinese version is now visible everywhere. This book combines WebLogic to introduce J2EE's development and deployment on the WebLogic platform, and practical guidance is very strong.

After mastering the basic knowledge of the Java platform and J2EE, it is further in learning how to use OO method for software design, so be sure to learn "design mode". Sun published a "J2EE Core Mode" is a book for each architect developing Java corporate platform software. This book fully introduces various design patterns of the J2EE architecture, which is a must-read book for designers.

Java Learning Path (3) Process

Every human learning method is different, and a person's method is not suitable for another person, I can only talk about my own learning method. Because I learned that Java is completely self-study, I have never asked others, so the process of learning is basically completely exploited. I don't know if this method is a better way, I can only give you a point.

The first step in learning Java is to install JDK, write a Hello World, "In fact, JDK's learning is not so simple, there are two questions about JDK, it is easy to have always plagued Java programmers: one is a classpath problem, in fact In principle, it is to figure out how JRE's ClassLoader loads Class; another problem is Package and Import issues, how to find the path problem of classes. Take all the two questions and clearly remove the biggest obstacles to learning Java and using JDK. It is recommended to look at Wang Sen's "Java Deep Adventures" and discuss these two issues.

The second step is to learn the syntax of Java. Java's grammar is class C , basic mainstream programming language is not class C, which is class C , there is no new thing, so the language of grammar is probably a half-day time. The only thing you need to pay attention is to have a few use, public, protected, private, static, when used, why is it used, how to use it, this may need someone to point to it, I originally complete myself I spent a long time. But then I saw "Thinking In Java" this book talking about these concepts. The third step is to learn the characteristics of Java's object-oriented programming language. For example, inheritance, constructors, abstract classes, interfaces, polymorphisms, overloading, coverage, and Java exception handling mechanisms. For a person without an object-oriented language background, I think this process takes a long time, because I don't have C experience before Java, only C's experience, I spent about a month, I only thoroughly It is clear that these concepts are clear, try to figure out, revise, try, and see the contents of the chapters, seeing, can't see 5 times, it is completely realistic. But I think if there is C experience, it should be enough for a day or two. So in this process, you can see "Thinking in Java" book, which is very thoroughly explained to the object. Unfortunately, when I learned, I didn't see this book, so I spent a lot of time, learning through my own trial and trying to learn.

The fourth step is to start familiar with Java class libraries. Java's basic class library is actually the JDK installation directory below JRE / lib / rt.jar this package. Learning the underlying library is to learn RT.jar. There are very many classes in the base class library. It is said that there are more than 3,000, I have no statistics. But really is only 4 of our most core, respectively.

Java.lang. *;

Java.io. *;

Java.util. *;

Java.sql. *;

The four packages of these packages, each package can be written into a thick textbook, and O'Reilly is indeed doing this. I think if the time is tight, it is impossible to learn from four books. I think the better learning method is like this:

First, you must read the entire package framework, understand the configuration of the entire package, interface, Exception, it is best to find an article describing the entire package framework. The first few chapters of these special introduction packages should be the introduction of these overall frameworks.

The grasp of the overall framework of the package is not to be familiar with each class, remember what properties, methods. I can't remember it. Instead, we must know what kinds of classes have a class, what is the use of these classes, and the most core of the core is done. When I gave it to the training, I generally speak a package, so I can't introduce the usage of each class, but I repeatedly stressed that I will tell you how to tell you how to call you. I don't ask you to remember the way the method is called, but I want you to know, what kind of Java provides us, every class is used, when I encountered a problem, I know which class, or Several combinations can solve my problem, That'All! When we write the program, as long as you know which class should be used to complete your job, it is enough. When encoding, the specific method is called, it is to write the code, check the documentation, all things are in the documentation, do not ask you to remember, actually can't remember more than 3,000 categories of total 100,000 methods transfer. Therefore, it is extremely important to grasp the grasp of the overall framework of each package. In the fifth step, through the above learning, if you are more solid, you have a foundation of Java, and the rest of the job is to clear the other more than 4 packs other than 4 packs. class. Believe this step, Java's self-study ability has been cultivated, and it can be reached the level of Documentation directly. In addition to doing GUI programming, other people who have use in JDK are these:

Java.text. *;

Java.net. *;

Javax.naming. *;

There are few more classes that are really used in these packages. There are only a few, so you don't need to spend a lot of time.

Step 6, Java Web Programming

The core of the web programming is the HTTP protocol, the HTTP protocol and Java have nothing to do. If you are not familiar with the HTTP protocol, although you can also learn the servlet / JSP programming, but you will not reach the realm of one and one. So the learning of the HTTP protocol is essential. If you are familiar with the HTTP protocol, there is a good foundation for Java programming. Learning Servlet / JSP is easy, I have to use the servlet / jsp use less than a week, and then start with JSP to do projects.

In the study of servlet / jsp, the weight is still servlet documentation. The most common class of servlet API is very small, and it can be mastered. Take these classes to see several examples. Servlet / JSP Programming Nature is to call these classes repeatedly between Web Server and Brower through the HTTP protocol. In addition to JSP, you need to be familiar with several common JSP tags, and if you can't hold it, the temporary investment is.

In addition, Java web programming learning is to be placed in the design mode of Web Application, how to analyze business logic, and conduct reasonable design, follow the requirements of MVC design mode, using servlet and JSP to complete different logical layers, master how The flow control and data sharing between servlet and JSP, and how Web Application should be configured and deployed.

Step 7, J2EE programming

If the above learning process is relatively smooth, the difficulty is difficult to improve. Because the above knowledge is only involved in one aspect, the J2EE specification such as EJB, JMS, JTA is often a crystallization of several Java technology, so it is relatively difficult to master. First, you must learn JNDI, JNDI is an App Server Location Server Resource (EJB Components, Datasouce, JMS) Finding Method, if you are not familiar with JNDI, EJB, JMS these things are almost university can't go. JNDI is actually javax.naming. * This package is easy to use. The difficulty is the configuration of the server resource file. For the configuration of the server resource file, you need to take a look at the special document specification, such as the WEB.XML of WEB.XML, EJB-JAR.XML Writings, and so on. For each different app server, there is also your own service resource profile, it is also familiar.

You can then learn JTA, mainly to understand the method of JTA's control for transactions, and what is used in any occasion. Here you can make an example, we know that the general situation can be transactional for a database connection (Conn.commit (False), ...., as an atomic operation, but assumes me Business requirements are to make operations for two different databases as an atomic operation, can you do? At this time, I can only use JTA. Suppose the operation process is first inserting a record first to the A database, then deleting another record of the B database, our own writing code is not controlling the entire operation as an atomic operation. With JTA, the APP Server is used to complete the control.

Learn to serialize and RMI before learning EJB, RMI is the basis of EJB. Then learn JMS and EJB. For EJB, the most critical is to understand how EJB is called by RMI to the call to the remote object, and in what circumstances to use EJB.

After learning EJB, JMS these things, you may be aware of the knowledge of two fields, one is UML, and the other is Design Pattern. Java Enterprise Software Design is very valid to the framework design, and a good software framework is a necessary condition for software development. At this time, you should start the focus of learning in design patterns and frameworks, master EJB design patterns and J2EE's core mode through learning and practical programming experience.

Inside the J2EE specification, there are many business technologies in addition to EJB, JMS, JTA, Servlet / JSP, JDBC, which is not introduced here.

There is also a new field Web Services. Web Services also does not have any new things, it is like a binder, you can unify different services to provide a unified call interface. As a user, I just get the WSDL for the service provider (on service Description), it is enough, I don't know if the service provider is EJB component, or is it .NET component, or what CORBA component, or other implementation, I don't need to know. The greatest place in Web Services is to achieve sharing of Internet services through unified service providing methods and calls, is a very exciting technical field. Web Services seems to have no good books, but can learn by checking information on the network.

Java Learning path (4) Method

As a programming language, Java is the best way to write code. When you learn a class, you can write a simple example program to run, see what results, then call a few classes, look at the run results, this is very intuitive to learn the class And the memory is very deep. Then you should not meet the transfer code, you should think about it, if I don't write, change it, try it again. Remember which talker said that learning programming is a destruction process, putting the examples in the book, learning the documentation, after running, constantly trying with different ways, constantly trying to destroy the structure of the code, see What is the result? In this way, you will be very universal to master Java.

For example, we have compiled Hello World

Public class helloworld {

Public static void main (String [] args) {

System.out.println ("Hello World");

}

}

Many beginners are not very understood why the main method must define the public static void main (String [] args), can you write? Including that I have such questions when I just learned Java. Want to know the answer? Very simple, you change your name to run, see what the report is wrong, then analyze according to the error information; take the main PUBLIC, try to see, what is wrong; Static removes; don't know main Whether or not to pass a string [] array, change String [], change to int [], or string to try; do not know if you must write the Args parameter name, you can also change the args to another name, Look at how to run the result.

I did this when I learned Java, I made the Hello World program for seven or eight times, constantly run, analyze the results, and finally understand why MAIN method is defined.

In addition, I don't understand the beginning of Staic, Public, Private, Exception, Try {} catch {} finally {}, etc., etc., it is to run successfully on the example above, and then start to destroy it, constantly According to questions in your own heart, rewrite the program, see if it is possible to run, whether it looks like it, can you get expected results. Thus, although time is time, an example program has repeatedly destroyed several times. I have a thorough understanding of this related knowledge. Sometimes even deliberately write some wrong code to run, see if it is expected to run error. This is to be profound for programming.

Specially 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 where the command execution is loaded, and the JVM is listed in order, through these valuable debugging information, can help us analyze what JVM has done in the process of execution.

In addition, in the learning process, this destruction routine written, should be consciously divided into a separate class, the typical routine accumulated in the work should also be organized regularly, and there is a code base in the month. I have encountered a similar problem, to the Copy & Paste, Search & Replace in the code base, which greatly improves the development speed. The most ideal situation is to abstract some universal routines to abstract the first floor, form a universal class library, and have good packaging. Then it is more reusable. So I don't think it is not particularly necessary. If you write the destruction routine is the best example. If you really write the code you wrote, I highly recommend you to see the JDK underlying class library Java source code. In the JDK installation directory, there will be a src.zip, unope can completely see the entire JDK base class library, which is the Java source code of RT.jar, you can refer to how Sun is how to write Java programs, specification What is it like. When I study Java's class library, when some places are not very clear, or when you want more clear understanding of the details of the operation, you often open the source code of the corresponding class, through the source code, all The problem will be swept away.

转载请注明原文地址:https://www.9cbs.com/read-107819.html

New Post(0)