All classes in the java package generate class, java package class

Source: Internet
Author: User

All classes in the java package generate class, java package class

Delimiter to change the behavior separator (this process is called class file registration ). These java files are not required to be related to each other. They can belong to different packages and be in different folders (of course, we recommend that java files with the same package path be placed under the same file path ), the javac command only reads the records in a row and performs class compilation as a unit.
Examples. Assume that your package is stored in the SRC folder, and the SRC parent directory is project. sourcelist.txt is also created in the project folder. First, register the java file you need to compile in this package with the src path (for example, src \ com \ test \ test.java.zip to the sourcelist.txt file; create a new bin folder in the project folder (or class folder, and name it as needed ), used to place the compiled class file (this configuration is understood by the-d option in the javac command); If there are other class libraries (such as jxl. jar or mysql. jar), we recommend that you create a new lib (also named but not limited) folder under the project directory, and then copy it to the folder (with the-classpath option for understanding). Finally, check that the above preparations are complete, win + R and Enter cmd. Now run the cd command in cmd to switch to the project directory, and then enter the command:
Javac-classpath lib/jxl. jar-sourcepath src @sourcelist.txt-d bin
It's easy to understand now. -D option indicates destination, that is, the generated class file is sent to the bin folder after this option;-classpath is to register the jar package you want to use into the class loading path; -sourcepath is used to tell the javac command where to find class files.
Finally, for convenience, you can create a bat file in the project folder and enter the following content:
Javac-classpath lib/jxl. jar-sourcepath src @sourcelist.txt-d bin
@ Pause
In this case, you can directly click the corresponding Java file and add or modify it in the sourcelist.txt file. This is actually a manifestation of "weak coupling" and modularization.

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.