0

I've installed Eclipse on a brand-new PC and copied over all of my projects from an old PC's workspace to the new one. Everything is set up the way that it should be as far as I can tell, however, the project refuses to run. I either get the message Editor does not contain a main type or a Select Java Application window appears with a list of a bunch of things, none of which are my application.

This project works perfectly fine on two other computers--one is a Mac, the other Windows.

The Build Path for all three computers is identical.

Yes, the public static void main(String[] args) method exists and has for years.

Java is installed, and it's the latest jdk-11.0.3.

Nothing has been changed, except that this is a new installation of Eclipse on a new PC.

Editor does not contain a main type in Eclipse: I have tried many of the suggestions here; none work.

Error: Selection does not contain a main type: Folder is already set as a source folder. No help.

Editor does not contain a main type: I don't work with Scala. Irrelevant.

I have not found anywhere else I can turn. No chat groups (Slack / Discord) appear to exist for Eclipse nor Java development.

Edit

Here are some supporting screenshots.

First, showing that the file structure is sound:

File structure is sound

And to show that the Build Path is configured correctly:

Build Path configured correctly

Finally, sometimes I will get this message instead of the "Editor does not contain a main type" error:

Select Java Application dialog

halfer
  • 19,824
  • 17
  • 99
  • 186
Sturm
  • 689
  • 2
  • 23
  • 52

2 Answers2

2

That error is happening because your Sample.java is not inside your src folder. Cut and paste (or just move) your class into your src folder and try again. Regards!

enter image description here

It will look like the image below when you are done.

enter image description here

jhenrique
  • 858
  • 1
  • 10
  • 17
  • I am sorry, @jhenrique, but this does not help, as far as I can tell. Please see my edits in the original post with the screenshots that show that I have a `/src` folder and that it does exist in the Build Path. – Sturm Jun 17 '19 at 13:12
0

It's a bug.

Turns out that all of my frustration is due to a bug introduced in Eclipse 4.11.

When running Eclipse 4.11 with JDK 11, sometimes a program that would normally run fine throws that error message. Thus, a simple downgrade to Eclipse 4.10 fixes the issue. (4.12 supposedly also fixes the issue, but it is still a Release Candidate as of this posting, so I'd rather avoid it for now.)

Credit for discovering this goes to Nune Isabekyan on The Java Specialists' Slack.

halfer
  • 19,824
  • 17
  • 99
  • 186
Sturm
  • 689
  • 2
  • 23
  • 52