Cannot run as java application in Eclipse, even have correct main() class

Keep in mind that projects imported from GIT are not necessarily java projects, as Eclipse understands this term. Is the project, as it exists in the repository, an Eclipse project? If it is, it should have two files in its root folder named .classpath and .project. If these two files are missing, you will need to instruct Eclipse to create them, with logical defaults. Also, if the root folder of the project has a pom.xml file, then it is a maven project, which is a whole different kettle of fish.


I was facing a similar issue. Below steps solved the problem:

  1. Import project from git
  2. Right click on Project -> Import -> Import as existing Maven Project
  3. One maven module will be imported, you can open .java file with main method from that module
  4. Right click, run as -> you can see the option.

If the project is already imported in your workspace, Right click on your and Configure > Convert to Maven... This will enable the Maven builder and force m2e configurators to setup all the required project natures on your project.

You can also install the m2eclipse-git connector to streamline the "import maven project from git" process. It should be available from Preferences > Maven > Discovery > Open Catalog.

Once it's done, you should import your project via Import...> Maven > Checkout Maven Projects from SCM