Compile java program manually

Source: Internet
Author: User

The help of javac, java, and javap is used to compile and execute programs composed of several files.

I encountered several problems:

1. Call between classes in the package

The directory structure is com/test/*. java.
[Java]
// A. java
Package com. test;
Public class {
New B ();
}
 
// B. java
Package com. test;
Class B {
 
}

In the test folder, use javac to compile B. after java, compile. in java, B cannot be found. In javap, the Class Name of B is com. test. b.
Therefore, during compilation, You need to compile in the top-level directory of com to complete the compilation of classes in the package.

2. When the main function class is running, the following command fails:

[Java]
Java com \ test \ ClassName // the current directory is the top-level directory of com

Check the command method in Eclipse and find that the running mode is
[Java]
Java com. test. ClassName
 

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.