1. Download J2sdk 1.4.1 or later (http://java.sun.com, it is recommended to download its Java documentation at the same time, this is the Java Help document)
2. Run just downloaded J2sdk-1_4_1_02-windows-i586.exe file for formal installation (the following assumptions installed in c:\j2sdk1.4.1, the recommended installation path should not have spaces, should not be installed in the \program Files directory!) )。
3. Set the operating environment parameters: a. If it is win95/98, add the following 3 line statements at the end of \autoexec.bat:
Set java_home=c:\j2sdk1.4.1
Set path=%java_home%\bin;%path%
Set classpath=.; %java_home%\lib
Note: Use the DOS command Notepad c:\autoexec.bat to open Notepad, add the above 3 lines of statement.
B. If it is WIN2000,XP use the mouse to right-click the "My Computer"-> Properties-> advanced-> Environment variables
System variable-> new-> variable name: Java_home variable Value: c:\j2sdk1.4.1
System variable-> new-> variable name: CLASSPATH variable value:.; %java_home%\lib
System variable-> edit-> variable name: Path at the front of the variable value plus:%java_home%\bin;
(There is an English period in the Classpath "." followed by a semicolon indicating the meaning of the current path)
4. Use a text editor (for example: edit.com/notepad/ultraedit/editplus) to write the following code and save it as a file: Helloworld.java (must be case correct!). assumed to be C:\test\HelloWorld.java)
<CCID_NOBR>
<ccid_code>/* Helloworld.java */public class HelloWorld {public static void main (String arg[]) {System.out.printl N ("Hello, world!"); }}</ccid_code>
</CCID_NOBR>
5. Open a DOS window, CD (that is, jump/change directory) to the directory where Helloworld.java resides
C:\>CD \test
C:\test>_
6. Compile Helloworld.java as Helloworld.class
C:\test>javac Helloworld.java
7. Run Helloworld.class
C:\test>java HelloWorld
Hello, world!.
C:\test>_
Note: If the exception in thread "main" java.lang.noclassdeffounderror:helloworld/javaerror:ccan′n appears Read:HelloWorld.java Mistakes like that, then write Javac and Java back.
If the bad command or file name indicates that the JAVAC command does not work, you need to: C:\>set path= "C:\jdk\bin" registers the command in the bin directory with this command
Also pay attention to case. (T111)