简体   繁体   中英

After importing into eclipse using eGit, can't compile and run. What do I do?

After importing a standard.java file into Eclipse using Git, I tried to compile and run the file. Eclipse gave me this error:

"Unable to launch: The selection cannot be launched, and there are no recent launches."

What do I do?

You must make sure your java code is in a java project. If the git source builds from ant, there is a "File>New>Other..>Java project from ant build file".

Otherwise you need to create a java project in eclipse and then 1) import the source into the proj /src directory or 2) create a linked folder in eclipse that points to the source location on the file system.

Then you need to set up the classpath (add any jars that are needed for the compile).

In the last screen of the Eclipse "Clone Git Repository" wizard, make sure "Import all existing Eclipse projects after clone finishes" is checked.

(Perhaps this option was not available 4 years ago when the question was posted.)

Not really git-related, I don't think. You just need to tell it which file to run. Right click on the file with the main() function in it, and click "Run As..." > Java Application

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM