Problems when running Java with cmd

Source: Internet
Author: User

One, cmd command

Switch to the D drive: D:

Enter a directory: CD newdir

View a directory of files under: Dir

Java compilation: Javac Helloworld.java, generates class file

Java Runtime: Java helloword.class

Ii. Javac is not an internal command or an external command

Step one: Access to the JDK environment download Step two: Install the downloaded JDK (my default installation letter is C:\Program Files (x86) \java\jdk1.6.0_10).     Note: There is no need to change the installation path step six: Now start the specific configuration environment right-click on "My Computer", select "Properties", then "Advanced", click "Environment variables", notice "System variables", click "New" three times, each time create a system variable (note case). Variable name: path     variable value: \ c \ default directory \ Bin     variable name: java_home     variable value: \ c \ default directory    variable name: classpath     variable value: \ c default directory \lib\tools.jar ; C: \ default directory \jre\lib\rt.jar; After the variable is created, click OK until the Properties window disappears. Step Seven: Open Notepad, enter this code (note case) class HelloWorld {public static void main (String args[]) {System.out.println ("Hello World"); }} Step eight: Save the file in Helloworld.java to D:\java Note: The save address is freely selectable and the file name is case-sensitive. Step nine: Go to "start"-"All Programs"-"Accessories"-"command Prompt" type Javac enter directly, after a few seconds to display the environment test results, the appearance of large English characters is normal. Step Ten: Replace the drive letter to the directory where the Helloworld.java file is located (d:\java>). Type Javac Helloworld.java after a few seconds to return to the directory where the file is located (d:\java>) compiled successfully. Typing Java HelloWorld Displays the Hello world after a few seconds

Third, cannot find or cannot load the main class

ClassPath:.; %java_home%\lib;%java_home%\lib\tools.jar
Java_home:d:\java\jdk1.8.0_11
Path:;%java_home%\bin;%java_home%\jre\bin;

Problems when running Java with cmd

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.