How to run a Java program written in Notepad _java

Source: Internet
Author: User

Today I wrote a Java program with Notepad, the test can run, now break it down into several steps to help you understand:

1. Create a new Notepad, the suffix name is. java, and then write a section of Java code inside, as shown:

2. Put the written Java file into D disk, is the first step given the class file;

3. Open the DOS interface to start-〉 run-〉cmd-〉 This is the command line mode, select D disk, as shown:

4. After selecting D, enter "Javac filename. java" at the command prompt, and my file name is Java, so enter Javac Java.java and return to wait for compilation. At this point you will find that it prompts that Javac is not an internal file. Next is the Java environment variable setting problem;

5. Download a JDK to perform the default installation. For example, my JDK version is: Jdk-6u10-rc2-bin-b32-windows-i586-p-12_sep_2008.exe;

6. Configure the Environment: Right click on My computer point properties, go into the high level can see the environment variables. Click here to set your system variable, as shown in figure:

6-1. Variable name: Classpath Variable Value: (.; C:\Program files\java\jdk1.6.0_10\lib brackets inside are all (mainly when we compile and run the program through Classpath can help us find some of the required system classes, "." The number is the current path; The number is used to separate multiple variable values, if your system has CLASSPATH environment variables, you do not need to create a new, directly add ";" , followed by a new value), as shown in the figure:

6-2. Variable Name: PATH variable value: (C:\Program files\java\jdk1.6.0_10\bin) parentheses are inside (usually the system already has the PATH environment variable, so just add the path to the path variable; because window s for external commands, search for executable programs in the path specified by the PATH environment variable, so you should add Java and javac paths to the path in order to execute commands such as Java and Javac. ) as shown in the figure:

7. After the bad environment is set up, you can go back to our fourth step, enter "Javac filename. java" at the command prompt, and my file name is Java, so enter Javac Java.java and then return to wait for compilation.

Appears as shown in the illustration, indicating that the compilation passed:

8. Then we can view our D disk with an extra Java.class file, as shown in the figure:

9. Next on the command line to enter the Java file name (such as mine is also Java, the name may be a little problem), as shown in the picture, our program can be run!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.