简体   繁体   English

eclipse无法运行主程序“找不到或加载主类错误”

[英]eclipse cannot run main “error could not find or load main class”

I am using eclipse oxygen. 我正在使用蚀氧。 I already had a java project downloaded, in the folder 我已经在文件夹中下载了一个Java项目

Documents/myJavaProjects/MyProject/

I opened eclipse and imported a project. 我打开了eclipse并导入了一个项目。 I made the workspace 我做了工作区

Documents/myJavaProjects

I opened the Project /MyProject/ 我打开了项目/ MyProject /

The path to Main.java is Main.java的路径是

/MyProject/myPackage/Main.java

Main.java has this: Main.java具有:

*/
package myPackage

public class Main {

  /**
   * Makes some sample calls to our Strategy classes.
   * @param args as usual
   */
  public static void main(String[] args) {

When I go to run configurations, the Java Application / Project and Main class does not show up. 当我去运行配置时,Java Application / Project和Main类没有显示。 How come? 怎么会?

Edit: when I try to type in "myProject"/ as the class and myPackage.Main , I get Launching configurring has encountered a problem. Launch configuration references non-existing project MyProject 编辑:当我尝试输入“ myProject” /作为类和myPackage.Main ,我得到“ Launching configurring has encountered a problem. Launch configuration references non-existing project MyProject Launching configurring has encountered a problem. Launch configuration references non-existing project MyProject

Name your Class exactly as the file.java . 将您的类命名为file.java。 End your main class and function with "}" 以“}”结尾您的主类和函数

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

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