简体   繁体   中英

Application compiles and builds on Netbeans but not as an independent jar file?

Is it possible that your application compiles and builds flawlessly in Netbeans but when you build it and run it outside of Netbeans you get heaps of Exceptions??! (keeping in mind that the all the libraries and dependencies are ported along with the actual jar file).

I run the followng command

ant -f run

and my program runs flawlessly as it's supposed to, however, where I run the following command to actually build a jar file,

ant -f jar

and when I run the jar file, my application runs but does not perform the tasks it does when it is launched using the first command.

Any ideas why this is happening??! I'm totally lost with this behaviour and can't find why!

If the exceptions are ClassNotFound, then it means that you're missing JARs in the CLASSPATH. NetBeans is sorting it out for you, but when you run outside of it you have to manage it yourself.

keeping in mind that the all the libraries and dependencies are ported along with the actual jar file

I'm not sure what the word "ported" ends up looking like for you, and without any real information I'm guessing, but your app isn't packaged correctly.

How are you attempting to build your project outside of NetBeans?

Inside NetBeans, if you created the project from within NetBeans, I believe that most of the time NetBeans will create all of its (by default) Ant targets in a file called nbbuild.xml .

Thus, if you're attempting to compile your project outside NetBeans from the command-line (however it exists on your system), you would then need to use the -f nbbuild.xml argument to the ant program to use the NetBeans-generated Ant file. So your command-line might look like this:

ant -f nbbuild.xml compile

Substitute, of course, the target you desire to run for compile in the example above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM