For example, how to configure environment variables and How to Run Servlet? There are too many such problems. Now I want to write a beginner entry, so that it can be helpful for beginners!
First, download the tool:
I suggest using Editplus + JDK for beginners. I think it is easier to use Editplus + JDK for beginners, such as JB, Eclipse, and JCreator, but it does not know how to configure environment variables for beginners, in this way, it is difficult to reach the point of knowing and knowing why.
You can download it at the following address:
Editplus (the latest version is v2.11): http://count.skycn.com/softdown.php? Id = 3641 & url = http://sc-http.skycn.net/down/epp211a_cn.exe (you need to follow the registration code to find it yourself, a lot of online)
JDK (the latest version is java2sdk3164_2): http://count.skycn.com/softdown.php? Id = 3116 & url = http://sc-http.skycn.net/down/j2sdk-1_4_2-windows-i586.exe (this is For Windows)
Then install JDK. I installed it under the c: JDK directory.
Then the CLASSPATH is set:
Just as the operating system uses PATH to search for executable programs, the Java Runtime Environment will traverse CLASSPATH to find classes. Even a simple program like HelloWorld, JVM will traverse every PATH defined by CLASSPATH, until the corresponding file is found.
I believe that if your system is not 2 K or XP, you should set the Path as follows:
My computer-> properties-> advanced-> Environment Variables
Then append the following Path to the environment variable: C: JDKin;.; C: JDKlib
You can also configure C: JDKin;.; C: JDKlibdt. jar; C: JDKlibools. jar.
★Remember: In the environment variables, remember not to be less. It indicates the current path. If there are fewer errors, you will say it!
Dt. jar is a class library about the runtime environment, and tools. jar is a class library about some tools.
If C: JDKin is not configured, "javac is not an internal or external command, or a program or batch file that can be run ." This error occurs.
Let's write an example program:
Open Editplus and create a new Java file. Follow the input below to keep it case sensitive:
Public class HelloWorld {
Public static void main (String [] args ){
System. out. println ("Hello, World! ");
}
}
Then save the file (ctrl + s) to HelloWorld. java. Java is case sensitive, so the case must be distinguished, that is, HelloWorld. java is not helloworld. java or other.
Run: Start-> Run-> cmd
Switch the directory to the current directory in the console:
Javac HelloWorld. java
Java HelloWorld
You will see the output Hello, World on the console!
Javac is a compilation command that compiles HelloWorld. java into HelloWorld. class.
Java is the command to explain. JVM will explain and execute HelloWorld. class.
At this time:
1. If Exception in thread "main" java. lang. NoClassDefFoundError: HelloWorld
That is, you didn't add that. (dot) to the environment variable)
2. If Exception in thread "main" java. lang. NoSuchMethodError: main
Or HelloWorld. java: 1: Public class helloworld must be defined in a file called
"HelloWorld. java ".
That is, you did not write this HelloWorld case-insensitive, or you did not save it as HelloWorld. java. This name must be the same as the public class name.
Let's talk about the problem of environment variables. Next, let's talk about how to compile and run the environment variables in Editplus, and choose Tools> parameter settings> Configure user Tools.
1. Add a tool (add an Application)
Menu text: Compile Java Program
Program: C: JDKinjavac.exe
Parameter: File Name
Initial Directory: file directory
2. Add a tool (add an Application)
Menu text: Run Java Program
Program: C: JDKinjava.exe
Parameter: File Name (excluding the extension)