Today, I wrote a JavaProgramThe test can run. Now we can break it down into several steps for your understanding:
1. Create a New notepad with the suffix. java. Then write a section of JavaCode,
2. Drop the written Java file into drive D, which is the class file given in step 1;
3. Open the DOS interface and start-> Run-> cmd-> This is the command line mode. Select disk D,
4. After selecting disk D, enter "javac file name. Java" in the command prompt and my file name is Java. Therefore, enter javac java. Java and press enter to wait for compilation. At this time, you will find that it prompts that javac is not an internal file. The next step is about setting Java environment variables;
5. Download a JDK and install it by default. For example, my JDK version is: jdk-6u10-rc2-bin-b32-windows-i586-p-12_sep_2008.exe;
6. Configure the environment: Right-click my computer node attributes and click Advanced to view the environment variables. Click in to set your system variables,
6-1. Variable name: classpath variable value :(.; c: \ Program Files \ Java \ jdk1.6.0 _ 10 \ Lib;) All the brackets (mainly we can use classpath to help us find some Required System classes when compiling and running the program, ". "#" indicates the current path; ";" is used to separate multiple variable values. If your system already has classpath environment variables, you don't need to create a new one. Add "; ", add a new value );:
6-2. variable name: PATH variable value :( c: \ Program Files \ Java \ jdk1.6.0 _ 10 \ bin;) It is in brackets (usually the system already has the PATH environment variable, therefore, you only need to add the path to the PATH variable. Because Windows searches for executable programs based on the path specified by the PATH environment variable for external commands, in order to execute commands such as Java and javac, add the paths of Java and javac to the path .) :
7. After the environment is set, we can go back to step 4,Enter "javac file name. Java" in the command prompt, and my file name is Java. Therefore, enter javac java. Java and press enter to wait for compilation.
Appears, indicates that the compilation is successful:
8. Then we can check that we have an additional java. Class file on drive D ,:
9. Enter the Java file name in the command line (for example, if my name is Java, it may be a small problem), and our program can be run!