Community
Participate
Working Groups
Using Eclipse 2019-03 I am getting the error "Selection does not contain a main type" when I try to run a class that obviously contains a main method (the code is already stripped down): package bla; import org.slf4j.LoggerFactory; // class from maven library import de.appicaptor.common.logging.LogUtils; // class for other project public class TestX { public void run() { } public static void main(String[] args) { TestX test = new TestX(); test.run(); System.exit(0); } } The class to be executed is located in a project that uses a lot of libraries via Maven (jar files from .m2 repo as well as Eclipse-Maven projects from the current Eclipse workspace). I narrowed it down to the import statements. If I remove one of the two import statements the main method is found again. All open projects are fully compiled (no compile or other errors shown in the Problems view). All projects use the JavaSE-11 runtime (AdoptOpenJDK 11.0.3 64bit hotspot for Windows). The Error Log view does not show anything that could be related to this problem. Restarting Eclipse, using -clean startup option, Updating all Maven projects does not solve this problem.
I found a workaround for this bug: When I select the main method in the "Package Explorer" tree view and execute the Run As -> Java Application command on this main method node I can execute the class without problems. Also the automatically generated Run configuration works. Only when I select the class in the Package Explorer tree view and select Run As -> Java Application I still get the error message "Selection does not contain a main type".
Probably duplicate of bug 545627.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.