NetBeans 不再为以前生成的代码生成 JAR 文件
两年前,我使用 Java 编写了一个简单的上传小程序,使用 NetBeans 开发。当我第一次点击“清理和构建”时,以及之后的一段时间,它运行得非常完美。它将运行整个构建过程并生成一个 JAR 文件,然后我可以将其上传到我的 Web 服务器,并且该小程序运行得很好。
现在,当我返回并对这个小程序进行一些细微修改时,当我点击“Clean & Build”时,它不再生成 JAR 文件。我所做的实际代码更改非常小,我可以保证它们不会对此产生任何影响(实际上只是更改了一些字符串的内容)。我知道自从我最初构建这个小程序以来,我的 NetBeans 已经自我升级了几次(现在我使用的是 6.9.1 版本),所以我想知道较新的版本现在是否存在某种错误。
不知道这是否有帮助,但此类是“自签名”的(在项目属性的“Web Start”选项卡中),下面我在底部包含了“clean,jar”窗格的输出NetBeans 的。我注意到它显示了 jar:
,然后没有说任何其他内容,而是直接跳到 BUILD SUCCESSFUL
。我假设中间应该发生一些事情?
init:
deps-clean:
Updating property file: C:\NetBeansProjects\MyApplet\build\built-clean.properties
Deleting directory C:\NetBeansProjects\MyApplet\build
clean:
init:
deps-jar:
Created dir: C:\NetBeansProjects\MyApplet\build
Updating property file: C:\NetBeansProjects\MyApplet\build\built-jar.properties
Created dir: C:\NetBeansProjects\MyApplet\build\classes
Created dir: C:\NetBeansProjects\MyApplet\build\empty
Compiling 1 source file to C:\NetBeansProjects\MyApplet\build\classes
C:\NetBeansProjects\MyApplet\src\MyApplet.java:189: warning: [unchecked] unchecked conversion
found : <anonymous java.security.PrivilegedAction>
required: java.security.PrivilegedAction<T>
Object doPrivileged = AccessController.doPrivileged(new PrivilegedAction() {
C:\NetBeansProjects\MyApplet\src\MyApplet.java:189: warning: [unchecked] unchecked method invocation: <T>doPrivileged(java.security.PrivilegedAction<T>) in java.security.AccessController is applied to (<anonymous java.security.PrivilegedAction>)
Object doPrivileged = AccessController.doPrivileged(new PrivilegedAction() {
2 warnings
compile:
Created dir: C:\NetBeansProjects\MyApplet\dist
jnlp:
Deleting: C:\NetBeansProjects\MyApplet\helper.txt
Going to create default keystore in C:\NetBeansProjects\MyApplet/build/nb-jws.ks
Generating Key for nb-jws
sign-jars:
generate-jnlp:
Copying 1 file to C:\NetBeansProjects\MyApplet\dist
Deleting: C:\NetBeansProjects\MyApplet\dist\launch.jnlp_
generate-html-preview:
Copying 1 file to C:\NetBeansProjects\MyApplet\dist
jar:
BUILD SUCCESSFUL (total time: 1 second)
Two years ago I wrote a simple upload applet using Java, developed using NetBeans. When I first hit "Clean and Build" back then, and for some time afterwards, it worked perfectly. It would run through the build process and produce a JAR file that I could then upload to my web server, and the applet worked great.
Now, as I'm going back in and making some slight modifications to this applet, it no longer produces the JAR file when I hit "Clean & Build." The actual code changes I made are so minute that I can guarantee they would have no bearing on this (literally just changing the contents of a few strings). I know that since the time I originally built this applet my NetBeans has upgraded itself a couple of times (right now I'm on version 6.9.1), so I wonder if the newer versions are now somehow buggy.
Don't know if this helps, but this class is "self-signed" (in the "Web Start" tab of the Project Properties), and below I've included the output of the "clean,jar" pane on the bottom of NetBeans. I noticed that it says jar:
and then doesn't say anything else but skips right to BUILD SUCCESSFUL
. I'm assuming that something should happen in between there?
init:
deps-clean:
Updating property file: C:\NetBeansProjects\MyApplet\build\built-clean.properties
Deleting directory C:\NetBeansProjects\MyApplet\build
clean:
init:
deps-jar:
Created dir: C:\NetBeansProjects\MyApplet\build
Updating property file: C:\NetBeansProjects\MyApplet\build\built-jar.properties
Created dir: C:\NetBeansProjects\MyApplet\build\classes
Created dir: C:\NetBeansProjects\MyApplet\build\empty
Compiling 1 source file to C:\NetBeansProjects\MyApplet\build\classes
C:\NetBeansProjects\MyApplet\src\MyApplet.java:189: warning: [unchecked] unchecked conversion
found : <anonymous java.security.PrivilegedAction>
required: java.security.PrivilegedAction<T>
Object doPrivileged = AccessController.doPrivileged(new PrivilegedAction() {
C:\NetBeansProjects\MyApplet\src\MyApplet.java:189: warning: [unchecked] unchecked method invocation: <T>doPrivileged(java.security.PrivilegedAction<T>) in java.security.AccessController is applied to (<anonymous java.security.PrivilegedAction>)
Object doPrivileged = AccessController.doPrivileged(new PrivilegedAction() {
2 warnings
compile:
Created dir: C:\NetBeansProjects\MyApplet\dist
jnlp:
Deleting: C:\NetBeansProjects\MyApplet\helper.txt
Going to create default keystore in C:\NetBeansProjects\MyApplet/build/nb-jws.ks
Generating Key for nb-jws
sign-jars:
generate-jnlp:
Copying 1 file to C:\NetBeansProjects\MyApplet\dist
Deleting: C:\NetBeansProjects\MyApplet\dist\launch.jnlp_
generate-html-preview:
Copying 1 file to C:\NetBeansProjects\MyApplet\dist
jar:
BUILD SUCCESSFUL (total time: 1 second)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,我不知道为什么它给我带来了麻烦,但我找到了解决方案。解决方案是简单地删除然后从头开始重新创建整个项目,然后再次尝试编译。我猜测 NetBeans 已经更新了他们在不同版本中执行清单文件或类似内容的方式,并且旧版本令人窒息。
Well, I'm not sure why it was giving me that trouble, but I found a solution. The solution was to simply delete and then re-create the entire project from scratch, and then try compiling again. I'm guessing that NetBeans has updated the way they do manifest files or something like that with the different versions, and it was choking on the older version.
Netbeans 7.1 也有同样的问题,并且项目是从 Netbeans 7.0.1 启动的。
构建项目时,jar 文件缺少一些文件,在我的例子中是 Main 类。
重新创建该项目也为我解决了这个问题。多谢!
Had the same problem with Netbeans 7.1 and a project started with Netbeans 7.0.1.
When building the project, the the jar file was lacking some files, in my case the Main class.
Recreating the project worked this out for me too. Thanks a lot!
选项 1:我尝试使用“以管理员身份运行”来运行 IDE。它帮助我正确创建 jar 文件
选项 2:
一个。运行“清理和构建”后,转到 Netbeans Maven 项目导航器并右键单击“使用修饰符执行目标”...
从“org.apache.maven.plugins:maven-jar-plugin:2.3.2:test-jar”中删除“test-”并选中所有复选框,如图所示下面(您可能想稍后通过选择“记住为”复选框来使用该命令)
我希望它会对某人有所帮助
Option 1: I tried to run the IDE with "Run as Administrator". It helped me to create the jar file properly
Option 2:
a. After running "Clean and Build" Go to Netbeans Maven Project Navigator and right-click on the Execute Goal With Modifiers...
b. Remove "test-" from "org.apache.maven.plugins:maven-jar-plugin:2.3.2:test-jar" and selecting all the checkboxes as shown below (You may like to use the command later by selecting the "Remember as" checkbox)
I hope it will help someone