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

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

问题描述

我已经开始将NetBeans 9.0与Java 10一起使用(孵化).我创建了一个新的测试Java应用程序项目,并在创建它时在使用专用文件夹存储库"('\ lib')上打了勾.我还将JDK/Java版本设置为10.然后,我将Apache Commons Codec 1.11包含为依赖项库.除了从主类的binary包中导入Base64类之外,我什么也没做.

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

这似乎是Java 10特有的,因为当我将JDK/Java版本更改为8时,它表现出预期的效果(已复制的库).

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

这有两个问题吗?

  1. Netbeans 9.0是否不完全支持Java 10,从而导致copyLibs任务静默失败?
  2. Java 10是否不支持相对于应用程序jar创建lib目录,还是我无法正确配置项目?

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

解决方案

我可以重现您的问题.

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

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

  • 按照错误中的详细说明编辑 nbproject/build-impl.xml .
  • 清理并构建项目.
  • 完成此操作后,将 commons-codec-1.11.jar 放在目录 dist/lib 中.
  • 但是,我仍然没有得到那个胖子.

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

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.

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.

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

Edit: 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.

This leaves two questions?

  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?

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.

解决方案

I can reproduce your problem.

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.

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:

  • 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.

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孵化-不在迁移或更新的Java 10项目的`dist`中建立`lib`目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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