Java Learning Summary (16.05.08) compiling and executing Java files using the cmd command line under Windows

Source: Internet
Author: User

using the cmd command line under Windows, you can invoke the Javac.exe and Java.exe in the JDK to compile and execute the Java files, provided that the JDK has been successfully installed and properly configured with the relevant environment variables (JDK installation and environment variable configuration method: http:/ /blog.csdn.net/qq_32099621/article/details/51339868)


Below is a look at how Windows uses the cmd command line to compile Java files
First find the Java files that need to be compiled and executed


Here I'm going to compile and execute this Java file
Press the key combination win+r call "Run", input cmd, enter the command line
Enter the letter containing the Java file with a colon (English)


In the example, the Main.java is in the D drive, so I entered D:
Then enter the CD space plus the path to the Java file (enter the directory where the Java file resides)


Then enter the Javac space plus the file name of the Java file (the suffix is omitted) to compile the Java file




After the compilation is successful, we can find a file with the suffix. Class in the directory of the Java file, which is the resulting file after the Java file is compiled.


Back to the command line, enter the Java space in the command line plus the name of the Java file (without the suffix), then you can execute the class file and get the results of the run


This is the run result of Hello java.
If you write the Java source code is wrong, the command line will appear prompt, follow the prompts to modify the source code.

Java Learning Summary (16.05.08) compiling and executing Java files using the cmd command line under Windows

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.