Java error: The main class could not be found or could not be loaded

Source: Internet
Author: User

This problem should be very common, I often manually compile some test code or gadgets, often used in Javac and Java to compile and run some simple gadgets.

Test it with Hello World.

Helloworld.java

 Public class helloworld{    publicstaticvoid  Main (String[]args)    {        System.out.println ("The romatic greet of programmer all over the World:hello world!" );    }}

The following is the compile command

Error when trying to run

The class HelloWorld could not be found.

Later, after the investigation, the final problem appeared on Classpath. When setting user environment variables, you need to add them in front of classpath.;

To find the current directory when looking for classpath.

The following are the normal running code

If the system environment variable is not modified, it can be set manually in the compilation file Classpath

Set classpath=.; %classpath%

You can also enter this command at the command prompt.

Java error: The main class could not be found or could not be loaded

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.