JDK installation should be said to be relatively easy, from Java's official website or in Baidu, it is easy to find, let the official website down: http://java.sun.com/j2se/1.4 .2 / download.html, huh, happiness is that there is also a simplified Chinese version on this page. It seems that it seems to be no more convenient.
The latest version of JDK now is
1.4.2
And packaged with Sun's open source development tool NetBean, of course, no NetBean. Unfortunately, I am not familiar with UNIX and Linux in addition to Window system, and you can only download the version of Window. Waiting for the opportunity to learn Linux or UNIX.
Don't say anything after the installation is downloaded. The result of the installation is: Of course, in the installation location, there is a folder (nonsense), this folder I have recently installed this time, I will understand what I understand, I don't understand. Add it again.
BIN directory: This is the commonly used tools, such as compiler JavaC.exe, and java.exe (what is it called?), and javadoc.exe seems to be able to extract what you can in the source program Out of the formation of documents (俺 俺 will not use), packaged JAR.exe (also not used), hey, will you do so much?
Lib Directory: It is said that this is the Java class library is in this folder, and the package and classes referenced by the import statement in the source program are mainly in this folder.
JRE directory: Java runtime environment. It is SDK, including JVM, class libraries, and other support files.
DEMO directory: example.
SRC compressed file: All original code of the class of Java2 core API, I thought I was here when I first installed the class.
In addition, there is still something here, I didn't know before: C: / Program Files / Java / J2re
1.4.2
_04, this is the Java runtime environment, I understand that the program is used after development deployment.
I finally wrote how it is configured, I didn't expect it to write so much!
How to configure JDK simply in the Internet, there is a lot of search, usually these three steps:
Add JDK's path in the environment variable, here is D: / J2SDK
1.4.2
/ bin;
Set the environment variable ClassPath as:.; D: / J2SDK
1.4.2
/LIB/dt.jar;d:/J2SDK1.4.2/lib/tools.jar, pay attention to the previous point;
Ok? No, I remember three steps, it's okay to finish the first two steps.
Oh, every time I am so happy to write a HelloWorld compilation, run, depressed things: general Javac is nothing, but I can't use Java, it is this famous error: Exception: EXCEPTION In thread "main" java.lang.noclassdeffounderror: helloworld, this is where I have no hand. Sometimes I can find an answer when I find it online, I will change myself, I will write down this time I haven't forgotten! ! !
The first step in the above is to let Javac, Java and other executable paths, to make Window can search them. The second setting of ClassPath I understand today. The program java.exe has a parameter is also classpath. This parameter is to tell Java.exe where to find the class when you run.
If the HelloWorld.java formed after compiling is under D: / Temp, you can write when running: java -classpath d: / temp helloworld, this is not problematic (provided is not The source program is used in package).
Well, if this is to write this time, don't you write this time? So it is also the same, so I set the environment variable ClassPath. It is to tell Java.exe to find the corresponding class in the path specified by ClassPath. That point Child (.) Is telling Java.exe to find it in the current directory.
Because the default path is generally: c: / documents and settings / username when running CMD, and .class files are generally not placed in this folder, so it is always wrong, if you execute in the directory where the .class file is located. Java, this is to find classes in that point (.) specified (current directory), it will not be wrong. It turns out that I am a stupid.
In addition, there is a problem that there is Package in the source program, and it is also a desperate interest. If there is no package in the source program, then run in the above method is no problem, if such a statement is written in the source program:
Package hello;
So, it should be like this:
Java-ClassPath D: / Temp Hello.helloworld
Compare what is different when there is no Package:
Java-ClassPath D: / Temp HelloWorld
Of course, if the current directory is appropriate, -classpath d: / temp is not necessary.
There is also the compilation. Class file must be placed ./hello directory, otherwise the following error: Exception in thread "main" java.lang.noclassdeffounderror: hello / helloWorld, depressed
The solution is to manually build a folder Hello in the current directory, then copy the .class file to the inside, huh, it seems to be more stupid. There is another way, that is, use Javac's parameter -D specified when compiled, where you want to put the class file, write:
Javac -d D: / Temp D: / Temp / HelloWorld (do not write: javac -d d: / temp / hello d: / temp / helloworld, because this time the Hello folder still does not exist)
You can generate a Hello folder in the directory D: / Temp, this time, if there is a problem, I am completely dizzy! !
Ok, this paragraph seems to be enough, but it is basically the case.