Javac Usage Summary

Source: Internet
Author: User

First, give a reference to the two links, and then summarize:

Content: compiling java files in multiple directories using JAVAC designation

Links: http://zhidao.baidu.com/link?url=W5ZERu8_ouGD-L_ Jh0vqqawhjnitsgbonqaatedyfzveo0gqb1yrdb3qcjba3fay7aibsdciburr1it4khckh1szra3e1u1iwlf_5iwlcbm

Overview: directory structure--project;

Project/src/com/package1/a.java;

Project/src/com/package2/b.java;

project/class///As output directory of the class

Project/sourcelist.txt//sourcelist.txt-bit source file list file, holding the relative path of the class to be compiled, such as: Src/com/package1/a.java

The Javac command reads only one row of its records and compiles the class as a single unit.

Project/lib/jxl.jar//External library

SourceList.txt content--src/com/package1/a.java//(or Project\src\package1\a.java;)

Src/com/package2/b.java

Execute the--javac-classpath lib/jxl.jar-sourcepath src @sourcelist in the project directory. Txt-d class

Content: How to run the entire Java project with Javac and Java compilation

Links: http://blog.csdn.net/huagong_adu/article/details/6929817

Summary: This article teaches you how to use Javac and Java commands, as well as how to use scripts (shell or BAT) to facilitate processing and demonstrate these usages with a simple example. (primarily for operations under Linux systems)

( wrong : The article says "Windows file path delimiter with \, file list delimiter with semicolons;" And I tested it myself: Windows 7 file path delimiter with [space space], file list delimiter with [carriage return])

Javac Use Summary:

Use the file directory structure above to illustrate

(where Package1 A.java has the class generated by the B.java that imported Packge2 B.class

A.java content--package Com.package1;

Import com.package2.b;

......

B.java content--package Com.package2;

......

The three ways to generate a project file are as follows:

1, CD into the project directory, in turn, execute

Javac-sourcepath src src/com/package2/*.java-d class

Javac-sourcepath src src/com/package1/*.java-d class-class -classpath class

This method is cumbersome, if there are more packages, you have to execute multiple statements, and there will be errors: The package is not found.

Only the class that has not been referenced is compiled first, and then the class that references it is compiled before it can be compiled successfully (that is, if the above two sentences are reversed in order, the first line will not be executed)

Also note: There is a class to import other packages, at compile time to give specific classpath, where the compiled class is placed in the class directory, so with -classpath class

The following two methods do not need to consider the order, as long as the files involved are written and can be

2, CD into the project directory, Javac-sourcepath src @sourcelist. txt-d class

(The method must write the specific relative path of all files one by one to the Sourcelist.txt (the file that mentions this list above), do not know can use wildcard character *)

1, CD into the project directory, Javac-sourcepath SRC Src/com/package1/*.java src/com/package2/*.java-d class

  (This method directly specifies all source file paths, separated by spaces (measured under Windows 7, available), wildcards *)

Javac Usage Summary

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.