Eclipse "error: Could not find or load main class" condition

Source: Internet
Author: User

Create a source file under a project and then run a copy of the code that will be download from the Internet. "Error: Unable to find or load main class" error: "The main class could not be found or could not be loaded", the whole project was built using MAVEN and then tried to run the phase The existing source files under the same package can be run, but deleting the file's target files (compiled files) again after the same problem occurs, which should indicate that all files under the current package have problems. It is strange that the project's "Build Path" be opened and then configure found that the directory where the package is located has been added to the source.It is absolutely an eclipse problem to create a. java file directly under Linux and then copy the same content, compile it directly with Javac, and run the discovery through Java. Search the Internet for a solution to this problem, but still can't, in this blog post (http://blog.sina.com.cn/s/blog_8723546a010181lj.html) found this problem caused by the same phenomenon as mine. I found my project under the jar of dependencies under Maven Dependecies also have a jar package is a red fork, this jar is Jdk.tools-1.7.jar, and then search for this file can not find the problem, found this blog (HTTP/ my.oschina.net/frankwu/blog/332873), So I used the second method of manually adding the JDK Tools.jar into the local MAVEN library, first into the native JDK directory in the Lib directory, and then run the following command: MVN install:install-file-dgroupid= Jdk.tools-dartifactid=jdk.tools-dpackaging=jar-dversion=1.7-dfile=tools.jar-dgeneratepom=true, as for this order what to do to search for it yourself. After joining, you can see the Red Fork Fork under Maven Dependecies is gone, and then run the Java file again, and find out! I'll rub it! I was about to be broken, so I daoteng a bit, in the build path under the order and export label will need to run the file of the package where the Classpath encountered the top (up or top), Determined to find this classpath indeed in the first place of the project, and once again hold the mentality of try, I le a rub, incredibly can, what is the reason ah, confused ...
At this time I was thinking that I have not like to use the integrated development environment for this reason, out of the question do not know how to solve, if you want to use these tools very well you need to write down the problems encountered, and then the next time you can know how to solve, or happen to be on the network has been met with you the same reason, The phenomenon is similar to the error, the latter can quickly help you solve the problem, but if you daoteng may waste a long time and a lot of bad mood. and directly in Linux with the command line, if you cannot find a file or other errors can be found in the error in most of the reasons, of course, pay is the cost of low efficiency. In fact, this and the use of some of the framework, or should be more familiar with many records, the problem of more thinking, more understanding of the underlying implementation principle, so that the problem to have a solution, and not on the integrated development environment or the framework of a little understanding, out of the problem can only be guessed.

Eclipse "error: Could not find or load main class" condition

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.