简体   繁体   English

蚀找不到主班

[英]eclipse could not find main class

I am trying to run a java program that has 3 classes and an .aj file. 我正在尝试运行具有3个类和.aj文件的Java程序。 I have my main named Main.class. 我的主名为Main.class。

When I'm trying to run my program it says it could not find my main class, even though it's right there. 当我尝试运行程序时,它说找不到正确的主类,即使它在那里。

爪哇

Eclipse is trying to run prob1.Main which doesnt exist. Eclipse尝试run不存在的prob1.Main By looking at your class you commented the package name. 通过查看您的课程,您commentedpackage名称。 Try recompiling your class again and run it. 尝试再次重新编译您的类并run它。

Don't comment out the: 不要注释掉:

  package prob1;

The only time you don't need to write the package is when you are using the default package for a project (which is created automatically when you create a class in a new project). 唯一不需要写该软件包的时间是当您为项目使用默认软件包时(在新项目中创建类时会自动创建该默认软件包)。 Edit the code snippet and then run the program again and it should be fine. 编辑代码段,然后再次运行该程序,应该没问题。 Hope this helps. 希望这可以帮助。

SomeTimes eclipse get corrupted run configuration...... For that issue three solution is there 有时eclipse的运行配置损坏了……对于该问题,存在三种解决方案

  1. Go to Run configuration setting , inside JAva Apllication you find your project, click on that, on right panel re-path you main class file path 转到“运行配置设置”,在JAva Apllication中找到您的项目,单击该项目,在右侧面板上重新路径您的主类文件路径
  2. if 1st doesn't work,take a backup of your main class ,delete it and re create new main class ,and copy the code from back up 如果1st不起作用,请备份您的主类,将其删除并重新创建新的主类,然后从备份中复制代码
  3. if 2nd failed .Close eclipse. 如果第二次失败。关闭日食。 Delete the .metadata directory. 删除.metadata目录。 Start eclipse. 开始蚀。 Import the projects. 导入项目。 Run the project again. 再次运行该项目。

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

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