NetBeans - How to Build Project jar file with all required libraries - java

I've tried to build my project with NetBeans 6.5; The thing is the project contains external jars added so I need them all being placed into my jar file (because it is to be signed); but IDE just places project classes in the jar :(
So my question is how to place project dependent external libs into my project JAR with NetBeans ?

I think you need something like this fat jar tutorial. I'm not sure if it's easier than building with an Ant script, but it should do the trick.

Related

Generating JAR on IntelliJ

I have some problems while creating a jar of my intelliJ project. First of all I just do the usual procedure:
Go to project structure
Select artifacts
Create a new one with modules and dependecies
Go to build artifact, build it
Execute it at console with java -jar "ddddd.jar"
So when I execute the project (not the jar) all runs ok, libreries and all works, but not in the JAR.
Terminal of IntelliJ:
My libraries are located in the project like: project>lib>"some jars here">otherjars>"here some jars and respective dll
This is because the "other jars" need the dll to work. I already tried to run them without the .dll but doesn't work without it.
Also I have them in the project on Modules>Dependencies I have the folder selected as a library.
Any help would be appreciated.
Edit 1:
Here I add some pictures about how I have my libraries structured.

Eclipse Java Build Path Jar Library classes not found even if available in jar

Recently I wanted to add the nebula shelf to my eclipse plugin. Therefore I added the org.eclipse.nebula.widgets.pshelf.source_1.1.0.201701302244.jar the build path of my eclipse project.
Sadly eclipse can't find the class files inside of the jar, even after cleaning and rebuilding the whole project.
Picture:
Checking the same jar file with jd-gui results in:
Picture:
I exported the *.java files with jd-gui and copied them to my project. Using this method my project built successfully and worked as expected.
Can someone tell me how I can use the jar file without exporting all of the java files manually? Thanks for your help! :-)
Do not use source jars. You can tell eclipse while debugging to use the source jar.
Add the jar to build path: right click on jar -> build path -> add to build path
Don't try to add Eclipse plugins directly to the build path of another plugin as it won't work.
Instead add the plugin to your target platform or import it in to your workspace.
Then add the plugin to your plugin's Dependencies. In the MANIFEST.MF editor you do this on the 'Dependencies' tab in the 'Required Plug-ins' list.

netbeans builds Maven projects jar file without dependent jar files

Could anyone would be so kind and explain how to make a single jar file with all maven dependencies in Netbeans Maven Java Application? In Eclipse user can Export to Runnable jar file and select Package required libraries into generated JAR, so all dependencies within project comes in created jar file. In Netbeans there is no such option.
I have checked other answers, but the only thing i understand is that I have to add code to Build.xml file which is not even in the project.
The last time I had to do this I used the Maven Shade Plugin. It allows you to create a single JAR file and also handles dependency clashes.
A simpler solution (which doesn't handle dependency clashes) is to use the Maven Assembly Plugin.
Note that these are pure Maven solutions which should work in any IDE.

how to package the .class under the web-inf/classes as a jar and put it to the web-inf/lib dir

I have a java web application name webapp,when I export it to a war,the source codes will be compiled to the WEB-INF/classes.
Now I want these classed be compressed to a jar,and put into the WEB-INF/lib.
I have tried this:
create a new java project named webapp_jar.
Copy all the source codes under the webapp/src to the webapp_jar/src,configurate the build path to make the project work.
Add the webapp_jar reference to webapp project.
However ,when I run the webapp,it seems that the classes defined at webapp_jar can not be found.
Is this possible?
BTW,I use the eclipse ee ide.
have you try ant https://ant.apache.org/ ?
you could make a jar and copy it to folder you want and build the war after.
But , if I anderstand, you would package all the app to a jar ?
I think your webapp can't work without a servlet or two ...
This is really easy to do with maven by creating two subject projects, one to build the war, and the other as a jar project and then use the jar project as a dependency on your war project which would put the jar inside the lib directory when packaging the war.
No I use the Web Deployment Assembly settings in eclipse. I worked.
You can find details here.

Copying a .jar file from my system to the disk -- is there a general solution for both .jar projects and non .jar projects?

My current project has a folder with dependencies, that is, .jar files. I was wondering if it'd be possible to copy any one of those .jar files to my disk.
I'm currently developing this project as a standard Eclipse Java project, but one day I'll want to deploy this project as a .jar file, too, so the solution would have to work both for the moment, and for the future situation as well.
Thanks
I Think this is what you are after:
Eclipse has an export function that also packages used library jars into the exported jar.
File->Export->Runnable Jar file -> Package Required libraries into generated JAR

Categories