Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run project in Eclipse imported from Git

I have a project in my Eclipse workspace from Github (via File -> Import -> Projects from GIT). However, I am unable to run the example because the only option I have under "Run As" is "Run Configurations."

After going to "Run Configurations" I click "browse" and the project that I imported from GIT isn't there.

Any ideas?

like image 582
emily Avatar asked Nov 26 '13 02:11

emily


2 Answers

The question is already answered in the comments but I am providing this answer to possibly clear up some misunderstandings.

In order to recognize a folder as a (Java) project, Eclipse needs to read (or create) a few files for each project, like .project and .classpath. If you do not have them in your project, or do no create them during the import, then Eclipse just imports it as a resource, or a dumb folder.

If your project is tracked by git and is also a maven project, you can clone it locally with Git (command line or GUI tool) and then "Import as existing Maven project" in Eclipse. This will use your pom.xml to create the two files mentioned above and your project will be buildable.

Alternatively, if you have already imported it as you described in your question, you can right click on your project on Package Explorer and choose Configure-->Convert to Maven Project. This will create the .project and allow you to build the project using Maven (right click->Run as..-> Maven build) and Eclipse's incremental builder (where necessary). If your maven project builds an executable, the option to execute it will also be available in the Run as.. menu.

If you have a more complex maven project (like an aggregate pom), and want a Run Configuration that runs a specific program, you will have to write it yourself by opening the Run Configurations window and explicitly referencing the java class.

like image 178
Yiannis Dermitzakis Avatar answered Oct 06 '22 00:10

Yiannis Dermitzakis


Don't import the project using git clone. Download it as zip file and extract it. Add it using Project>import> General> Projects from folder and Archive. Provide path of extracted folder into import source and finish and go to eclipse and clean and build safely run and right click on project and run it. It should work

like image 28
Pradhuman Singh Avatar answered Oct 05 '22 22:10

Pradhuman Singh