eclipse 如何运行从github下载的源代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35119239/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 23:02:30  来源:igfitidea点击:

How to run source code downloaded from github

javaeclipseantdevelopment-environment

提问by Shady Programmer

This is getting quite frustrating lately as I've downloaded various source codes for various programs from github and I don't know how to build them or run them. Now mind you, I'm not new to programming but this particular area of not knowing how to get things started when I get someones project files is absolutely killing me. What I have is this:

最近这让我很沮丧,因为我从 github 下载了各种程序的各种源代码,但我不知道如何构建或运行它们。现在请注意,我对编程并不陌生,但是当我获得某人的项目文件时不知道如何开始这一特定领域绝对让我丧命。我有的是这样的:

Source files

源文件

What am I supposed to do now to build and run one of their examples ?

我现在应该做什么来构建和运行他们的一个例子?

Before anyone starts hatin' on me for that question:

在有人开始讨厌我这个问题之前:

I've read the manual that was attached with these files and it gives general overview of what can be found in the folders and so on but they don't specify how to build it. Also I have eclipse for Java set up and tried to import these files as a project but eclipse rejected and said that no project can be found. I tried running individual java files but couldn't get them to compile because there was no "ant file" ( what is going on ? ) Later on I found something which I think was that ant file and opened it in conjunction with the file I wanted to run but no success.

我已经阅读了这些文件随附的手册,它概述了文件夹中可以找到的内容等,但没有指定如何构建它。此外,我设置了 Eclipse for Java 并尝试将这些文件作为项目导入,但 Eclipse 拒绝并说找不到项目。我尝试运行单个 java 文件,但无法编译它们,因为没有“ant 文件”(这是怎么回事?)后来我找到了一些我认为是那个 ant 文件的东西,并将它与我的文件一起打开想跑却没有成功。

采纳答案by Julien Revault d'A...

This is a maven and ant project, you need to download and install maven : https://maven.apache.org/

这是一个maven和ant项目,需要下载安装maven:https: //maven.apache.org/

And download and install ant: http://ant.apache.org/

并下载安装ant:http: //ant.apache.org/

The build.xml file is the configuration for ant The pom.xml is the configuration for maven

build.xml 文件是ant 的配置 pom.xml 是maven 的配置

Look inside the ant.xml, you will find "<target ..." elements. For example one target is build, to run it just opent a commande line and :

查看 ant.xml 内部,您会发现“<target ...”元素。例如,一个目标是构建,运行它只需打开一个命令行,然后:

ant build

回答by FlowX

You have to import the Project!

您必须导入项目!

  1. From the main menu bar, select command link File > Import.... The Import wizard opens.

  2. Select General > Existing Project into Workspace and click Next.

  3. Choose either Select root directory or Select archive file and click the associated Browse to locate the directory or file containing the projects.

  4. Under Projects select the project or projects which you would like to import.

  5. Click Finish to start the import.

  1. 从主菜单栏中,选择命令链接文件 > 导入...。导入向导打开。

  2. 选择 General > Existing Project into Workspace 并单击 Next。

  3. 选择“选择根目录”或“选择存档文件”,然后单击关联的“浏览”以找到包含项目的目录或文件。

  4. 在项目下选择您要导入的一个或多个项目。

  5. 单击完成开始导入。

help.eclipse

帮助.eclipse