java-cmd-command line compile and run Java files

Source: Internet
Author: User
I. Tools used

1.javac

2.java

Two. command

The project directory is just like this

D:/project/src/com/example/child.java

D:/project/src/com/example/parent.java

D:/project/src/com/example/main.java---Main method entry

This method is suitable for cases with packages or no packages

1. Compiling

d:project> javac-d src\com\example\classes-sourcepath src Src\com\example\*.java

2. Running

d:project> Java-classpath src\com\example\classes Com.example.Main

Three. Explanation

1. Javac- D "The target path of the compiled class file" -sourcepath src "source file to compile, support wildcard"

2. java -classpath "The address of the class file to run " " Run Portal"

java-cmd-command line compile and run Java files

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.