When running the java file in cmd, the solution of the main class cannot be found or loaded.

Source: Internet
Author: User

When running the java file in cmd, the solution of the main class cannot be found or loaded.

Recently I looked at java again, but it had been a headache for more than a decade by a seemingly basic hellorworld. Baidu once, if you edit and run the. java file in cmd and report an error, the solution is as follows ,:

The. java file in the root directory of drive D.

Open cmd and enter the root directory of drive d For javac demo. java ,:

In this step, no error is reported, because as long as your classpath is set successfully, no error is reported,

Now we can see that the compiled demo. class has already appeared in the root directory.

When we proceed to the next step, we will find the cmd error ,:

I believe that many new students have encountered this problem, which is time-consuming and laborious for Baidu to query. Sometimes some people write a solution that won't solve the problem at all.

Then we can directly handle the problem. This kind of problem is often caused by incomplete classpath configuration.

:

In the classpath of the environment variable, add "." at the beginning of the variable value, and then run cmd again to solve the problem ,:

For how to configure environment variables, see the previous java Configuration Guide.

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.