Netbeans 9.0 Incubating - 不为迁移/更新的 Java 10 项目在 `dist` 中创建 `lib` 目录 [英] Netbeans 9.0 Incubating - Does not make `lib` directory in `dist` for migrated/updated Java 10 project

查看:22
本文介绍了Netbeans 9.0 Incubating - 不为迁移/更新的 Java 10 项目在 `dist` 中创建 `lib` 目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始在 Java 10 中使用 NetBeans 9.0(正在孵化).我创建了一个新的测试 Java 应用程序项目,并在创建它时勾选了使用专用文件夹来存储库"(\lib").我还将 JDK/Java 版本设置为 10.然后我将 Apache Commons Codec 1.11 作为依赖库包含在内.除了从主类的 binary 包中导入 Base64 类之外,我没有做任何其他事情.

I have started using NetBeans 9.0 (incubating) with Java 10. I created a new test Java Application project and ticked 'Use Dedicated Folder for Storing Libraries' ('\lib') when creating it. I also set the JDK/Java version to 10. I then included Apache Commons Codec 1.11 as a dependency library. I didn't do anything else, other than import the Base64 class from the binary package in the main class.

但是,当我构建应用程序时,NetBeans 不会在 dist 目录中创建 lib 目录,也不会创建包含 org.apache.commons.codec.* 库中的包.

However, when I build the application, NetBeans doesn't create a lib directory in the dist directory, nor does it create a fat Jar that includes the org.apache.commons.codec.* package(s) from the library.

这似乎是 Java 10 特有的,因为当我将 JDK/Java 版本更改为 8 时,它的行为符合预期(复制了库).

This seems specific to Java 10, because it behaved as expected (copied libraries across) when I changed the JDK/Java version to 8.

我看到了其他问题(关于其他版本的 Netbeans 和 Java)的各种答案,这些问题提出了各种 targetcondition放置在构建脚本中的片段以覆盖 build-impl.xml,我已经尝试无效.

I have seen various answers to other questions (about other versions of Netbeans and Java) that put forth various target and condition fragments to place in the build scripts to override build-impl.xml, which I have tried to no effect.

这就留下了两个问题?

  1. Netbeans 9.0 是否不完全支持 Java 10,导致 copyLibs 任务无声地失败?
  2. Java 10 是否不支持创建相对于应用程序 jar 的 lib 目录,还是我未能正确配置项目?
  1. Does Netbeans 9.0 not fully support Java 10, causing the copyLibs task to fail silently?
  2. Does Java 10 not support creating a lib directory relative to the application jar or am I failing to configure the project correctly?

注意: 测试项目的目的是诊断我是否可以重现影响较大项目的问题,该问题需要更新以使用较新版本的 Java.旧项目使用了我工作的公司内部开发的许多库.我们没有设置和迁移到基于 Maven 的构建系统所需的资源,并且仍在使用 Ant.

Note: The purpose of the test project was to diagnose if I could reproduce an issue affecting a larger project that needs to be updated to use a newer version of Java. The old project uses a number of libraries developed internally by the company for which I work. We do not have the resources necessary to set up and migrate to a Maven-based build system and are still using Ant.

推荐答案

我可以重现您的问题.

不幸的是,这是一个 NetBeans 9.0 错误.请参阅 NETBEANS-1097 如果源/二进制格式"是 JDK 9 或 JDK 10,则复制依赖库"不起作用.

Unfortunately this is a NetBeans 9.0 bug. See NETBEANS-1097 "Copy Dependent Libraries" does not work if "Source/Binary Format" is JDK 9 or JDK 10.

该错误描述了一种可能的解决方法,Halvor 的回答中也提到了该方法.但是,尽管这似乎对您不起作用(根据您的评论),但它对我部分起作用:

That bug describes a possible workaround which is also mentioned in Halvor's answer. However, although that does not appear to work for you (based on your comment), it partially worked for me:

  • 按照错误中的详细说明编辑 nbproject/build-impl.xml.
  • 清理并构建项目.
  • 完成后,commons-codec-1.11.jar 被放置在目录 dist/lib 中.
  • 但是,我还是没有拿到那个胖罐子.
  • Edit nbproject/build-impl.xml as detailed in the bug.
  • Clean and build the project.
  • After doing that commons-codec-1.11.jar is placed in directory dist/lib.
  • However, I still did not get the fat jar.

我尝试的另一件事是{project}> 右键单击​​> 属性> 库,然后编辑库文件夹 字段,将其从相对路径更改为绝对路径小路.这似乎并没有让事情变得更好或更糟.

One other thing I tried was {project } > right click > Properties > Libraries, then editing the Libraries Folder field, changing it from a relative path to an absolute path. That did not seem to make things better or worse.

这篇关于Netbeans 9.0 Incubating - 不为迁移/更新的 Java 10 项目在 `dist` 中创建 `lib` 目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆