[英]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.使用 Git 将 standard.java 文件导入 Eclipse 后,我尝试编译并运行该文件。 Eclipse gave me this error: Eclipse 给了我这个错误:
"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.您必须确保您的 java 代码在 java 项目中。 If the git source builds from ant, there is a "File>New>Other..>Java project from ant build file".如果 git 源代码从 ant 构建,则有一个“文件>新建>其他..>来自 ant 构建文件的 Java 项目”。
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.否则,您需要在 eclipse 中创建 java 项目,然后 1) 将源导入proj /src 目录或 2) 在 Z6B7B655DD22FAA3F10677C512493A 上指向文件的源位置的 Z6B7B655DD22FAA3F10670C512493A 目录中创建链接文件夹。
Then you need to set up the classpath (add any jars that are needed for the compile).然后您需要设置类路径(添加编译所需的任何 jars)。
In the last screen of the Eclipse "Clone Git Repository" wizard, make sure "Import all existing Eclipse projects after clone finishes" is checked.在 Eclipse“克隆 Git 存储库”向导的最后一个屏幕中,确保选中“在克隆完成后导入所有现有 Eclipse 项目。”
(Perhaps this option was not available 4 years ago when the question was posted.) (也许这个选项在 4 年前发布问题时不可用。)
Not really git-related, I don't think.我不认为与 git 相关。 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右键单击包含 main() function 的文件,然后单击“运行方式...”> Java 应用程序
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.