简体   繁体   English

在Eclipse没有选项的情况下如何建一个Java项目

[英]How do you build a Java project in Eclipse when no options are available

I am trying to build a Java project I found on Github using Eclipse. The project has no maven & gradle files and no.jar files in the repo.我正在尝试使用 Eclipse 构建一个我在 Github 上找到的 Java 项目。该项目在 repo 中没有 maven 和 gradle 文件,也没有 jar 文件。 I am getting the following error when I try to build the project within Eclipse. "No actions available."当我尝试在 Eclipse 内构建项目时出现以下错误。“没有可用的操作。” Also, When I select the option, Right-click the project and choose Configure > Configure and Detect Nested Projects, this is not working.此外,当我 select 选项时,右键单击项目并选择配置 > 配置和检测嵌套项目,这不起作用。 Please see the images attached.请参阅所附图片。 This is the current repo I am trying to run, https://github.com/copley/def-guide-to-java-swing.git这是我正在尝试运行的当前回购协议, https://github.com/copley/def-guide-to-java-swing.git

在此处输入图像描述 在此处输入图像描述 在此处输入图像描述 在此处输入图像描述 在此处输入图像描述

The notion of "build" and "run" are different. “构建”和“运行”的概念是不同的。 You stated that you get "No actions available" when you build it, but your screenshot clearly shows that you're trying to execute the "Run As" operation.你说你在构建它时得到“没有可用的操作”,但你的屏幕截图清楚地表明你正在尝试执行“运行方式”操作。

You said "The project has no maven & gradle files and no.jar files in the repo".您说“该项目在回购中没有 maven 和 gradle 个文件,也没有 jar 个文件”。

First, do you know what a "maven file" is?首先,您知道什么是“maven 文件”吗? Your screenshot shows a "M" in the project icon.您的屏幕截图在项目图标中显示了一个“M”。 That shows that Eclipse recognizes that project as a Maven project.这表明 Eclipse 将该项目识别为 Maven 项目。 Do you have a "pom.xml" file in the project?项目中是否有“pom.xml”文件? That is the file that declaratively specifies to Maven how to build this project.那是声明性地指定 Maven 如何构建这个项目的文件。

Second, what do you mean by "no.jar files in the repo"?其次,“回购中的第 jar 个文件”是什么意思? What repo are you talking about?你在说什么回购协议?

In the top screenshot, where you attempted the "Run As", it appears that you selected one of the Java source files, not the project itself.在顶部屏幕截图中,您尝试“运行方式”时,您似乎选择了 Java 源文件之一,而不是项目本身。 The "Run As" operation can only work if it knows how to run the object that you've selected. “运行方式”操作只有在知道如何运行您选择的 object 时才能工作。 If you've selected a Java source file, it will only be runnable if that class has a "main()" method with the proper signature.如果您选择了 Java 源文件,则只有当该 class 具有具有正确签名的“main()”方法时,它才可运行。

The other curious problem is that the github project you cite has no source file named "ColorSample.java", or even a folder named "Ch01".另一个奇怪的问题是您引用的 github 项目没有名为“ColorSample.java”的源文件,甚至没有名为“Ch01”的文件夹。 That project uses Maven for all its examples, and a couple of sample classes I looked at all have "main()" method with the proper signature.该项目的所有示例都使用 Maven,我查看的几个示例类都有带有正确签名的“main()”方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Eclipse中的Android项目中使用Java项目? - How do you use a Java project in your Android project in Eclipse? 如何在Eclipse中为Java,Scala和JRuby打开单个项目? - How do you open a single project for Java, Scala and JRuby in Eclipse? 如何在Eclipse中构建Java项目以创建外部JAR - How do I build a Java project in Eclipse, to create an external JAR 如何在 eclipse 中构建基于 maven java 的项目 - How to build maven java based project in eclipse 如何在NetBeans的Java项目中的Eclipse中包含来自Scala项目的文件 - How do you include files from a scala project in eclipse in a java project in netbeans 你如何在eclipse中向svn添加项目? - How do you add a project to svn in eclipse? 如何在 Eclipse 中同时构建我的自定义 java 包和项目? - How do I do in Eclipse to build my custom java package and project at the same time? 在java中,如何将一个项目导入另一个项目而不将它们放在同一个(Eclipse)工作区中? - In java, how do you import one project into another without having them in the same (Eclipse) workspace? 我在Eclipse中有一个Java项目。 我如何获得它,以便您可以在终端中运行它? - I have a java project in eclipse. How do I get it so you can run it in the terminal? 在依赖于其他两个项目的Eclipse Java项目中,如何解决jar冲突? - In an Eclipse Java project that is dependent upon two other projects, how do you resolve jar conflicts?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM