如何在不默认使用 Maven 的情况下在 Netbeans 中创建 Java 项目?

How to create Java project in Netbeans, without using Maven as default?

我目前正在尝试创建一个基本的 Java 项目。出现的第一个选项是 "Java with Maven",我已经使用过,但没有提供我需要的 "Create Main Class" 选项。

我在 Windows 10 上使用 Apache Netbeans IDE 11.0,运行,x64。 我花了一整天的时间更新和安装我找到的最新 JDK 版本,但我仍然无法让它工作。

我也读过这个答案,但它不起作用:

这是我得到的图像:

感谢任何帮助,谢谢。

在 Apache NetBeans 11.0 中修改了项目模板,使 Maven 项目更加突出。来自 Apache NetBeans blog post:

Restructuring of Project Templates in Apache NetBeans

There's been lots of discussion in the Apache NetBeans community about how best to express the fact that Apache Maven and Apache Gradle are more modern choices to be aware of than Apache Ant, while at the same time not implying that there's anything wrong with using Apache Ant.

Here's what we seem to have reached consensus around, i.e., move all Ant-based project templates into a separate Ant-specific folder, while putting the other two build systems higher and therefore more prominently in the list:

With the above, someone is less likely to simply go to the no-longer-existing Java category and then end up with an Ant-based project, without thinking about it. By default, the user of Apache NetBeans is now encouraged to consider Apache Maven and Apache Gradle first. The old Ant-related categories are still there, so as not to confuse anyone completely, just structured within a lower ranked "Java with Ant" category. The above also solves the discussion re "Java EE", i.e., here the idea, from discussions, is to name the category "Java Enterprise".

At startup, all categories are closed, i.e., none is more prominent initially than any other.

An objection one could have is that, if you're a complete Java newbie, you won't know what Maven, Gradle, or Ant are. Well, that has always been the case and NetBeans has artificially hidden that choice by having a category simply named "Java", which then resulted in everyone ending up with Ant-based projects. To turn that around and have a category simply named "Java" that results in Maven-based projects is probably not right either, i.e., a careful balance needs to be struck.

因此,如果您在早期版本的 NetBeans 中使用 File > New Project... > Java > Java Application 创建了一个项目,您应该使用 File > New Project... > Java with Ant > Java Application in NetBeans 11.0.

备注:

  • NetBeans 错误报告 NETBEANS-2040 Maven First in New Project Wizard 参考。
  • 另请参阅此 YouTube 视频开头的讨论 The Rough Guide to Apache NetBeans 11.0
  • NetBeans 11.0 中的其他项目向导更改:
    • 在 NetBeans 11.0 中,我必须安装 Gradle 插件(工具 > 插件 > 可用插件 > Gradle)才能看到 Java 和项目向导中的 Gradle
    • 在较早版本的 NetBeans 中,您使用 File > New Project...> Java EE > ... 创建了一个 Java 企业项目,但在 NetBeans 11.0 中,这已更改为 File > New Project...> Java with Ant > Java Enterprise > ...