NetBeans is no longer generating a JAR file for code that it used to

∥☆過路亽.° 提交于 2019-12-02 12:26:29

问题


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)

回答1:


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.




回答2:


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!




回答3:


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



来源:https://stackoverflow.com/questions/5514672/netbeans-is-no-longer-generating-a-jar-file-for-code-that-it-used-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!