I'm using some apache HttpClient jars, so I put them in my project's lib directory, when Netbeans compiles the project, it copies the lib and generated a project jar into dist directory, but when I run my project with webstart, I need to copy the project jar and lib into tomcat's ROOT dir, I wonder if Netbeans can generate a project jar that includes all the jars in the lib dir, so I don't have to copy the project jar and the lib dir into tomcat's ROOT dir. Can Netbeans do that ?
相关问题
- Dependencies while implementing Mocking in Junit4
- Step by step instructions for getting cppunit up a
- org.jdesktop.application package doesn't exist
- Error when installing TDA package on R
- Don't want netbeans debugger to go to disassem
相关文章
- java.lang.NoClassDefFoundError: javax/servlet/http
- unable to install packages(“caret”) completely in
- Java: Look and Feel
- Default arguments in JAR-manifest
- C++ compiler error in netbeans
- How to escape @ sign inside JSDoc comments in NetB
- php: auto indent the whole code?
- PHP friend/package visibility
That's really easy to package every dependent library (*.jar) into one single myProject.jar.
Just follow these steps and you will finally pack every dependent library into single jar. If you are using NetBeans then you can follow exactly or else you need to find your build.xml file in project files.
Follow these steps to edit build.xml
1) Click on
Files tab
on the left side of the project panel in NetBeans.2) Double click on the
build.xml
file and add these lines in it just before</project>
line3) Change
value
in second line of the code as per your project name which is4) Save it and right click on build.xml and choose Run Target and then Other Targets and finally click on Package-for-store
5) And here you done. Now you can go and check just like
dist
folder there will be astore
folder which will be containing your final complete jar including all of your dependent libraries. Now whenever you want to change / add more libraries or so, just follow step 4.Picture for step 4
OK, found the answer at the following site : http://arunasujith.blogspot.com/2011/08/how-to-build-fat-jar-using-netbeans.html
Okay, so this is my solution. I too had the problem with my program compiling and running on Netbeans but it failing when I tried
java -jar MyJarFile.jar
. Now, I don't fully understand Maven and I think this why was having trouble getting Netbeans 8.0.2 to include my jar file in a library to put them into a jar file. I was thinking about how I used to use jar files with no Maven in Eclipse.It's Maven that compiles all the dependencies and plugins, not Netbeans. (If you can get Netbeans to do this please tell us how.)
[Solved - for Linux] by opening a terminal.
Then
Next
Next
This will create jar file in the target directory.
Now
(You may need to run: chmod +x MyJarFile-1.0-jar-with-dependencies.jar) And finally
Please see
https://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException
Robert Eckstein describes a solution for this problem. You just need to paste the following code to
build.xml
. The libraries are all found automatically.Here we go:
Go to your build.xml, and add the code right before the closing project tag at the end.
Now change the value of the first propertiy field as commented
Click Clean & Build, and your jar will be in the dist folder
Reference link: https://stackoverflow.com/a/30172829/2761273