简体   繁体   English

Eclipse项目中的类路径问题

[英]issue with classpath in eclipse project

Most likely pilot error. 最有可能的飞行员错误。 I have a project which was building correctly but not anymore. 我有一个正在正确构建但不再存在的项目。 I have checked the build and run path settings and could not find anything incorrect (neither in the classpath file). 我已经检查了构建和运行路径设置,找不到任何不正确的内容(在classpath文件中都没有)。 I am posting relevant content below - any suggestions to troubleshoot this issue will be quite welcome (other than unfreezing my brain). 我将在下面发布相关内容-非常欢迎提出解决此问题的建议(而不是动脑筋)。 All my jar files are in the lib directory and are referenced as such - however, when I run the project, I get a "Could not find or load main class" exception. 我所有的jar文件都在lib目录中,并且被这样引用-但是,当我运行项目时,出现“找不到或加载主类”异常。 I have a public static void main(String[] args) method in a class in the project (there is no other main method in the project). 我在项目的类中有一个公共的静态void main(String [] args)方法(项目中没有其他main方法)。

I have a main class specified in the run configurations (this class contains the main method). 我在运行配置中指定了一个主类(此类包含main方法)。

Update : I was able to recreate the project as a new eclipse project and build/run cleanly. 更新 :我能够将项目重新创建为新的Eclipse项目并干净地构建/运行。 Trying to figure out what caused the issue (still unresolved) with the previous project. 试图找出是什么原因导致了先前项目的问题(仍未解决)。

Second Update I had added a JRE directory in the project but I thought it was not being referenced. 第二次更新我在项目中添加了一个JRE目录,但我认为没有被引用。 Removing it from the parent directory fixed the issue with running the project. 从父目录中删除它可以解决运行项目的问题。 It was the same version as the default JRE on the system/eclipse. 它与系统/ eclipse上的默认JRE版本相同。

I had a JRE directory in my project (which I had added earlier for testing) - this was the same JRE (I believe) that was being used by Eclipse/system. 我的项目中有一个JRE目录(之前已经添加了JRE用于测试)-这与Eclipse / system使用的JRE(我相信)相同。 Simply removing the JRE allowed the project to run correctly. 只需删除JRE,即可使项目正常运行。 I will reconfirm later whether there was a minor version mismatch between the JRE's somehow. 稍后,我将再次确认JRE之间是否存在次要版本不匹配的情况。 Hope it helps others. 希望它能帮助别人。

Have you checked .classpath file is correct. 您检查过.classpath文件是否正确。 Since your code is not compiling you wont generating .class file Hence you would be getting "Could not find or load main class". 由于您的代码未编译,因此您将不会生成.class文件。因此,您将获得“无法找到或加载主类”。 If possible try clean and build trough ant script 如果可能,请尝试清理并构建槽蚂蚁脚本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM