1. Introduction
JDK (Java Development Kit) is the foundation of all java applications. It can be said that all java applications are built on this. It is a set of APIs, which can also be said to be some java Classes. The latest version that has been officially released is JDK1.3. Considering that I am not familiar with Linux and most of them are under MS system, I use win2000 here.
2. Download and install.
The download address is the official JAVA site: java.sun.com, which is also available everywhere in China.
Under Windows, run the .exe file directly and install it into a directory. I use F:jdk13 as an example here.
3.
Select "My Computer" on the configuration desktop (right-click)
Advanced
environment variables,
go to "System Variables" ---> "New"
, enter: CLASSPATH in the variable name, enter:
F:JDK13LIBdt
in the variable value.JAR;F:JDK13LIBTOOLS.JAR;F:JDK13BIN;Then confirm;
OK, the configuration is complete, and the environment variables can only be effective after restarting the computer.
4. Test
(1) Use a text editor to write a simple java program:
public class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
This example is The famous "Hello World", its function is to display "Hello World".
Note: The file name must be "HelloWorld.java" and is case-sensitive. Careful friends will notice that it is the same as the name after public class.
(2) Compilation: Execute at the dos command prompt: (note the case)
javac HelloWorld.java
If normal, the HelloWorld.class file will be generated.
(3) Run: Execute at the dos command prompt: (note the case)
java HelloWorld
Here is a problem that Java beginners are likely to encounter (not afraid of jokes, me too) is to enter:
java HelloWorld.class
There are too many behind .class, be sure to pay attention, otherwise the following error will occur:
Exception in thread "main" java.lang.NoClassDefFoundError:HelloWorld/class
(I wonder if java replaced "." with "/" when translating ".", Or there are other reasons that I don’t know)
Well, running java HelloWorld should produce a great “Hello World”.
At this point, you have successfully configured the JDK and can start the long and painful process (for friends like me who did not understand Java before, it can be described as "painful", because they do not understand the concepts and are not familiar with Java. api..., but don't worry, I will slowly get started with everyone and slowly improve the Java process of...).