如何将预先存在的Java项目导入Eclipse并启动并运行?
对重复参考的评论:为什么在被问为重复的问题之前多年被问到时,为什么将其标记为重复? 我还认为问题,细节和响应比所提到的问题要好得多。
我已经成为C
++程序员已有一段时间了,但是我是Java和Eclipse的新手。我想使用触摸图“图形布局”代码来可视化我正在使用的某些数据。
这段代码是这样组织的:
./com./com/touchgraph
./com/touchgraph/graphlayout
./com/touchgraph/graphlayout/Edge.java
./com/touchgraph/graphlayout/GLPanel.java
./com/touchgraph/graphlayout/graphelements
./com/touchgraph/graphlayout/graphelements/GESUtils.java
./com/touchgraph/graphlayout/graphelements/GraphEltSet.java
./com/touchgraph/graphlayout/graphelements/ImmutableGraphEltSet.java
./com/touchgraph/graphlayout/graphelements/Locality.java
./com/touchgraph/graphlayout/graphelements/TGForEachEdge.java
./com/touchgraph/graphlayout/graphelements/TGForEachNode.java
./com/touchgraph/graphlayout/graphelements/TGForEachNodePair.java
./com/touchgraph/graphlayout/graphelements/TGNodeQueue.java
./com/touchgraph/graphlayout/graphelements/VisibleLocality.java
./com/touchgraph/graphlayout/GraphLayoutApplet.java
./com/touchgraph/graphlayout/GraphListener.java
./com/touchgraph/graphlayout/interaction
./com/touchgraph/graphlayout/interaction/DragAddUI.java
./com/touchgraph/graphlayout/interaction/DragMultiselectUI.java
./com/touchgraph/graphlayout/interaction/DragNodeUI.java
./com/touchgraph/graphlayout/interaction/GLEditUI.java
./com/touchgraph/graphlayout/interaction/GLNavigateUI.java
./com/touchgraph/graphlayout/interaction/HVRotateDragUI.java
./com/touchgraph/graphlayout/interaction/HVScroll.java
./com/touchgraph/graphlayout/interaction/HyperScroll.java
./com/touchgraph/graphlayout/interaction/LocalityScroll.java
./com/touchgraph/graphlayout/interaction/RotateScroll.java
./com/touchgraph/graphlayout/interaction/TGAbstractClickUI.java
./com/touchgraph/graphlayout/interaction/TGAbstractDragUI.java
./com/touchgraph/graphlayout/interaction/TGAbstractMouseMotionUI.java
./com/touchgraph/graphlayout/interaction/TGAbstractMousePausedUI.java
./com/touchgraph/graphlayout/interaction/TGSelfDeactivatingUI.java
./com/touchgraph/graphlayout/interaction/TGUIManager.java
./com/touchgraph/graphlayout/interaction/TGUserInterface.java
./com/touchgraph/graphlayout/interaction/ZoomScroll.java
./com/touchgraph/graphlayout/LocalityUtils.java
./com/touchgraph/graphlayout/Node.java
./com/touchgraph/graphlayout/TGAbstractLens.java
./com/touchgraph/graphlayout/TGException.java
./com/touchgraph/graphlayout/TGLayout.java
./com/touchgraph/graphlayout/TGLensSet.java
./com/touchgraph/graphlayout/TGPaintListener.java
./com/touchgraph/graphlayout/TGPanel.java
./com/touchgraph/graphlayout/TGPoint2D.java
./com/touchgraph/graphlayout/TGScrollPane.java
./TG-APACHE-LICENSE.txt
./TGGL ReleaseNotes.txt
./TGGraphLayout.html
./TGGraphLayout.jar
如何在Eclipse中添加此项目并使其快速编译和运行?
回答:
在Eclipse中创建一个新的Java项目。这将创建一个src文件夹(以包含您的源文件)。
还要创建一个lib文件夹(名称不是那么重要,但是遵循标准约定)。
将
./com/*
文件夹复制到文件/src
夹中(您可以使用OS进行此操作,而无需执行任何高级导入操作或从Eclipse GUI中执行任何操作)。将所有依赖项(
jar
项目本身依赖的文件)复制到/lib
(请注意,其中 包含TGGL jar
- 感谢评论者Mike Deck指出了我对OP帖子的误解! )将其他TGGL内容复制到根项目文件夹(或其他一些专用于许可证的文件夹,您需要在最终应用程序中分发这些许可证)
返回Eclipse,选择在步骤1中创建的项目,然后按F5键(这将刷新Eclipse的文件夹树视图,并包含实际内容。
/src
文件夹的内容将自动编译(将类文件放置在Eclipse在创建项目时为您生成的/ bin文件中)。 (您不在当前项目中,但出于完整性考虑,我将在此包括在内),最后,根据需要
/lib
在Eclipse中打开文件夹,然后选择构建路径。right click``jar file``Build Path->Add
这会将特定的jar添加到项目的类路径中。Eclipse将检测到更改并自动编译之前失败的类,现在您应该拥有一个包含您的应用程序的Eclipse项目。
以上是 如何将预先存在的Java项目导入Eclipse并启动并运行? 的全部内容, 来源链接: utcz.com/qa/403574.html