Solution with Package Java program not working under terminal after compilation

Source: Internet
Author: User

For example, the following section of the source code (the source code is Cay S. Horstmann "Java Core Technology Volume 1: Fundamentals (10th edition English)" in the fifth chapter of the source):

Package abstractclasses;

Import java.time.*;

compile with Javac.

Then use Java and find always prompt "error: The main class could not be found or could not be loaded"

This is a very strange question.

The solution to the problem was later found to be simple:

1, first in the source code directory under the operation:

Javac-d. *.java

will produce a directory.

2, and then run

Java abstractclasses.persontest

to function properly.

Where abstractclasses is the package name. It is important to note that you do not switch directories.

The above is the problem solved in terminal. Is the same in CMD under Windows.

Solution with Package Java program not working under terminal after compilation

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.