Java使用Eclipse出现editor does not contain a main type解决

  • run时出现editor does not contain a main type
    Java使用Eclipse出现editor does not contain a main type解决

原因:当前源代码没有整合进package,即没有build path

  • 部分已经build path,但新写的代码没有

解决方案

  • 若已经有build path(有红褐色标记),则先Remove;没有(全白)则忽略
  • src(右键)-> build path -> remove from build path
    Java使用Eclipse出现editor does not contain a main type解决
    Java使用Eclipse出现editor does not contain a main type解决
  • 此时,src文件全部变白
  • 然后点击:src(右键)-> build path -> use as source folder
    Java使用Eclipse出现editor does not contain a main type解决

完成效果

Java使用Eclipse出现editor does not contain a main type解决