Java compilation specifies the package file

Source: Internet
Author: User

Usually write helloworld. Java

After javac helloworld. Java is compiled in the current directory, Java helloworld can be executed.

However, if the source file belongs to a package, such as the package HKUST. Cse. se,

You can also compile javac in the current directory, but the class cannot be found during Java helloworld (because the Java Virtual Machine thinks the package must correspond to a path)

Therefore, make sure that the. Java file is stored in the whatever/HKUST/CSE/SE/directory. At this time, no matter which directory you compile the javac file, you only need to locate the. Java file to compile it successfully,

When running, you need to Cd The working directory to whatever and then Java HKUST/CSE/SE/helloworld

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.