Java study notes - preparation stage

zhaozj2021-02-17  55

Author Note: This article is a record of Java, perhaps a little help like this. It may not have to look at the masters.

One day, in the form of a form (actually the boss is underway), I have to start learning Java. The short-term goal of learning, one is to use the JSP or Java Beans Connection Operation Database (Sybase), and the other is to develop a control of block diagrams that can draw graphs, histograms, and table shapes using Java. Long-term goals are - no longer a rookie in Java ^ _ ^.

1. Preparation stage a) JDK's download and installation learning Java's first step in course is a JDK, from the Sun's website, a installation package containing NetBeans3.5.1 (J2SDK-1_4_2-NB-3_5_1-bin-windows . Double-click the installation directly, install it under C: / Program files / J2SDK_nb using the default path, then you need to enter C: / Program Files / J2SDK_NB / J2SDK1.4.2, which is a bit long, so it is later Strict criticism. After installing JDK, the setting of three environment variables (java_home, classpath, path), using Win2K, estimated that the possibility of 9X after the estimation is not big, so only the 2K setting method: right click on me Computers, click Properties, select advanced pages, point environment variable buttons, OK, can be set. It turned out that there is no Java_Home and ClassPath, which requires new, corresponding values ​​as follows: java_home = C: / Program Files / J2SDK_NB / J2SDK1.4.2 (strongly recommended that all the same rookies like me do not use the default path); classpath = C: / Program FILES / J2SDK_NB / J2SDK1.4.2 / LIB / Tools.jar; C: / Program Files / J2SDK_NB / J2SDK1.4.2 / lib / dt.jar (suggestions are the same, and there are additional supplements); additional needs to increase C: / Program files / j2sdk_nb / j2sdk1.4.2 / bin, you can use JDK Javac, Java and other tools on the command line. If you never use a command line tool, you should not set it (?). However, in order to expose a professional, it is still good. OK, the Windows system is simple to operate, JDK is installed so.

b) Selecting development tools to do good things, must first sharpen them. The JDK environment is installed, and you should choose a development tool to handle it. I used to use the notepad to write the Java program, I feel that this is relatively pure. Later, I gave up, because two aspects, one is no automatic indentation, but no automatic function. People now have been hampered by various integrated development environments. First, I saw Eclipse, which was used next to it, I haven't heard it before. Hurry to copy and install it, and find it without installing ^ ^ after decompression. Send a shortcut to the desktop, ok, start ... ah, is E text. The fourth level is over, but it is N years ago. In order to ensure the progress, give up first. Then found NetBeans installed at the same time when installing JDK, did not notice when installed, and I still want this JDK package so big (more than 90 m). The official site (www.netbeans.org) of NetBeans has a Chinese version. Know that it is Sun mainly pushed Java IDE (if you don't bundle with JDK), it is developed by Java, the latest version is 3.5.1, which is very complete. Double-click to start spend a little time (slow), then update online, it can finally be used. The interface seems to be more clear. It is more likely the management of its file system, and you can directly pick up the local orientation to the file system. In addition, its execution does not need to be configured, it can be used directly. Whether it is primary, JSP (embedded Tomcat4.0.0.6), or applet, click the Run button to run quickly. This is very important, especially for what I don't understand what ClassPath is. The tool is ready, you can start the first Java program. (Originally, it should be recorded, and it is all right (version 4.1.27), it is also installed (directly to extract it, ^ _ ^). However, since NetBeans already bring, it will not cost it, although the version is slightly Low, it should be enough to use it.) C) The first program is always starting with Hello World. For me, the Hello World program means that the entire preparation work is successfully completed. Create a class Hello in NetBean, write code. / ** * hello.java * @Author Aberlee * Date: 2003-11-01 * Time: 09:09:33 * email: aberlee@msn.com * / public class hello {public static void main (String args " ) {System.out.println ("Hello World!");}}

Before this, I have already understood that "everything is object" in Java, and all Java programs consist of one or more Class. One can run Class, must be public, must contain the main function, the main function must also be public and static, and the statement of the Java output characters to the console is system.out.println (). Click to run, the "Hello World!" Statement is successfully printed in the run window below NetBeans. So, I'm already guilty, I have been prejudial to Java, just because I read a Hello World to try, often, or through compilation could not run. Try to open the console. Go to the source code current directory, knocking: Java Hello (Enter) expected Hello World did not appear, the mistakes that were often seen before. Exception in thread "main" java.lang.noclassdeffounderror: Hello used to play only, when you encounter problems, you won't worry, but now you must solve it. Look at the source code, like the exact same, even if you are wrong, you should not be wrong in this program. And it is clear in NetBeans. Look at the word Noclassdefounderror, it seems to be the reason for this Class. Even if you want to run a file in Linux, even if it is also added ./, for example ./install.pl. I think the reason for the wrong reason may be related to classpath, and NetBeans have not reported because it has its own classpath settings (Open the NetBeans option, which is true, and there are many types of path options). Then you can use Java parameters to try it. Java-ClassPath. Hello (note having a point, this point represents the current path) Haha, finally run successfully, it seems to be in this regard. Now add the current path to the system's ClassPath environment variable, so you don't have to knock on the parameters each time. Classpath = .; C: / Program Files / J2SDK_NB / J2SDK1.4.2 / lib / Tools.jar; C: / Program Files / J2SDK_NB / J2SDK1.4.2 / lib / dt.jar (above mention this added ^ _ ^ The preparation phase is over, and the real Java should be started to begin.

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

New Post(0)