Javac compiled successfully, "The main class cannot be found or cannot be loaded" appears in Java running class file

Source: Internet
Author: User

Javac compile successfully, the problem of "cannot find or Load main class" appears in Java running class file.

Learn Android, and learn Java by the way.

The introduction encountered such a problem, the environment variable according to the online said, the direct Java and Javac are prompted to come out, stating that no problem,

Made a simple Java, placed in the e-packing directory, under the C: Operation Javac The Java file succeeded, but the Java class when the "can't find or load the main class", Busy half a day, find some information, found in fact very simple, not a statement error, is a problem classpath the path problem.

The main point is the following two points to note:

1, in the front of the classpath to add a directory path, with. To indicate that, since there is also the Java DT and tools two paths, so. to add;    

2, more importantly, run Javac and Java under CMD, must run in the directory of the Java file, so that the generated class is also in the directory, Java will be the first in this directory to find the class file, will not be prompted to find. This cmd run path due to general less attention, the input cmd will go directly to the C + + personal folder, and the general Java file will be written with other software, placed in the selected path, these two paths can rarely be active coincident, a run of course cannot find, but Javac can recognize, I don't know why Java is a hint. This is a bit strange. On-line solutions are rarely noticed in fact that this small problem caused by the lack of class, all take for granted that the Java source file path to run Java, that of course, can not find the basic problem lies.

if 1, 2 did not change, that is, the computer changed the environment variable after the need to restart the new settings to take effect, restart the next.

resolves the above two points and will no longer prompt "cannot find or Load main class"

(Note: reproduced from http://wl1975sdm.blog.sohu.com/220057382.html)

Javac compiled successfully, "The main class cannot be found or cannot be loaded" appears in Java running class file

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.