简体   繁体   English

Eclipse不会编译成bin,无法找到或加载主类

[英]Eclipse won't compile into bin , Could not find or load main class

I've been using eclipse to program in java for a month or two now. 我一直在使用eclipse在java中编程一两个月。 I have a package boats, within it many classes all run from the main class boatGame. 我有一个包船,其中很多类都是从主类船游戏中运行的。 Eclipse has built and rebuilt the numerous iterations of my program until today, when it seems to have stopped cooperating. Eclipse已经构建并重建了我的程序的众多迭代,直到今天它似乎停止了合作。 When I hit run, I get the error, 当我跑步时,我收到错误,

Error: Could not find or load main class boats.BoatGame

When I investigated, I found that the Bin folder is empty and devoid of the replicated source file components as .class files. 当我调查时,我发现Bin文件夹是空的,并且没有将复制的源文件组件作为.class文件。 An unrelated program would run from eclipse, but when I deleted it's bin file components, it too gave me the same error, with its bin folder also remaining completely empty. 一个不相关的程序将从eclipse运行,但是当我删除它的bin文件组件时,它也给了我同样的错误,其bin文件夹也保持完全为空。

My default output folder is boats/bin, and a search of my computer didn't yield any .class files that may have been built in the wrong place. 我的默认输出文件夹是boats / bin,搜索我的计算机时没有产生任何可能在错误位置构建的.class文件。 I have also deleted and re-installed both eclipse and JDK. 我还删除并重新安装了eclipse和JDK。 Does anyone have any pointers as to how I could start building programs within eclipse again? 有没有人有关于如何再次开始在eclipse中构建程序的指示?

我在项目名称上运行了重构/重命名,然后将其重命名为原始版本并修复了问题。

This problem occurs with me too. 我也会遇到这个问题。 Here is the solution: 这是解决方案:

1. Open the folder in which the .java files are present of the project boats (boats/src). 1.打开项目艇(boat / src)中存在.java文件的文件夹。

2. Now, go to eclipse and make a new project. 2.现在,去eclipse做一个新项目。 (boatsA or boatsB, whatever you like). (船只A或船只B,无论你喜欢什么)。

3. Make the same(name) classes as in boat (it may take time). 3.制作与船上相同的(名称)课程(可能需要时间)。

4. Copy the text in each .java file and paste it in respective classes. 4.复制每个.java文件中的文本并将其粘贴到相应的类中。

5. Save all classes. 5.保存所有课程。

6. Run it! 6.运行它!

I am 100% sure that it will run. 我百分百肯定它会运行。

Though in your case, it may work. 虽然在你的情况下,它可能会工作。

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

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