. Advertisement .
..3..
. Advertisement .
..4..
The error
selection does not contain a main type
occurred when I run some java files in a new project. I’ve tried to fix it for some days but have not resolved it yet. Can someone suggest a relevant solution to fix the selection does not contain a main type issue? Much appreciate your support.
The cause: You have this problem because the code the tutorial is trying to run is not in the correct package even though the package name has been entered at the beginning of each class.
Solution:
Select
Refactor
andMove To
from the context menu and right-clicked on each class, then agree to the suggested package name.Run
As
…Java Application
as normal after that.The selection does not contain a main type issue will be fixed.
Right-click on the folder in which you have placed your main class, then click
Build Path
–->Use as Source Folder
.Final step: Run your main file as a java application. We hope this will solve your problem.
If you do not see the option “Use as Source Folder” in the ‘Build Path”, then select the option “Remove From Build Path”. This will make the ‘Use as Source Folder” option appear in the Build Path’.