I am using eclipse to build the EAR of my project. So I have various module and several utility jar in my application deployment descriptor(refer fig 1). Now my problem is when I am trying to export the EAR using eclipse, the EAR file is properly containing the content of Module but Project utility jar is not being exported(look at the size of jar file in ear which is 181 bytes ). Could you please suggest me how can I achieve that.What do I need to modified so that utility jar exported properly
Finally I have found the answer to my question after head crunching research. The problem with my application was the corrupted value in the "org.eclipse.wst.common.component" file. Which can be found in the .setting folder of you project. The above mentioned file had the duplicate entry for the same project. So default process was getting confused which path to include. I have manually removed the duplicate entry and the issue resolved.
Modify the MANIFEST.MF file of the EAR project to add the utility JARs
Related
I have created a JavaFX application using NetBeans IDE and below is my folder structure.
I want to a build a single jar file including all dependencies for this jar to work properly.
This jar requires testplanner and batch folder from project root directory and files inside dist folder to work properly.
How can I package all this to a single jar file?
Theoretically JAR files cannot contain dependencies within, as java does not support it out of the box. WAR and EAR archives can. What You want to do is not standard, but is named fat jar. Fat jars are used i.e. by spring-boot maven plugin, but you could try this:
https://dzone.com/articles/how-build-fat-jar-using
And some more explanation:
NetBeans - deploying all in one jar
Use tecreations Deploy. Put all your sources into a path declared as Tecreations.getProjectPath(), run BuildAll to create your corresponding classes, put your jars in projectpath/jars and select the appropriate settings, whether to include jars, sources or classes. Select your main class and click Deploy. Unsigned and signed output jars are produced in user/Documents.
Download: https://tecreations.ca/java/downloads/release.
My problem is with a project where I use the POI library. It's from apache and allows you to work with excel,word, ... .
I had to add some jar files to my library and it runs perfect.
The problem is when I put my JAR file somewhere else.
It gives me the errors it can't find the librarys.
Is there a way I can put my librarys into the 1 jar?
I already tried to add my lib folder as source package but that didn't help.
there is a Maven plugin for Eclipse called M2Eclipse, which will read a POM and construct a classpath out of jars it finds in the local repository and any remote repositories you've configured. It behaves largely like Maven does in terms of finding the latest version for a given jar (if you've specified a version range in your POM).
You can also have a look on this
http://fredpuls.com/site/softwaredevelopment/java/deploy/five_strategies_for_managing_j.htm
You want to make a 'shaded' or 'uber' jar, which has all of its dependencies included
There is a maven plugin for building a shaded jar.
https://maven.apache.org/plugins/maven-shade-plugin/
For me the fastest/ easiest solution was to just open my project in eclips and export is a runable JAR then it adds the librarys to the JAR.
NetBeans builds your application into the project's dist folder. There is also a readme file in it, that tells you, you should distribute the contents of that folder...
Edit
Remove the lib folder, that is shown on the second image, from your sources.
I have been looking around for some time now, but didn't a find way how to export a JAR (not runnable jar) that contains in it's build path the referenced libraries.
Using Eclipse, I have included the lib folder which contains the jars of the referenced libraries in the export process.
Importing that JAR to another project and calling some method results in a ClassNotFoundException.
Looking at the MANIFEST, I didn't see any reference to those jars in the classpath, though the jars are indeed included in the jar.
So my questions are:
1. Is there any way to accomplish the packaging of the non-executable JAR so it will include libraries?
2. Is there any best practice for building and deploying a jar that include other jars libraries?
I tried it too but it doesn't work for me. I added the final .jar file but it doesn't work.
So, I did a workaround.
Extract the .jar file that you want as a dependency.
Copy that content and put it all inside your .jar file.
Add your .jar file as dependency inside an eclipse project.
Run it and see if everything is ok.
We are in process of migrating our project from Ant to Maven. While doing this migration we are facing difficulties in finding dependencies between jars that are used in Ant. I just want to know main jars which are needed to mention in pom.xml and the remaining jars will be automatically downloaded.
In short I want to know how to find dependecies amongst JAR files used in our project.
There is a tool from JBoss project called JBoss TattleTale, might be worth taking a look:
The tool will provide you lot more then just dependencies finding :
Identify dependencies between JAR files
Find missing classes from the classpath
Spot if a class/package is located in multiple JAR files
Spot if the same JAR file is located in multiple locations
With a list of what each JAR file requires and provides
Verify the SerialVersionUID of a class
Find similar JAR files that have different version numbers
Find JAR files without a version number
Find unused JAR archives
Identify sealed / signed JAR archives
Locate a class in a JAR file
Get the OSGi status of your project
Remove black listed API usage
And generate the same reports for your .WAR and .EAR archives
I would suggest you use jarAnalyzer which will traverse through each of the jar files in that directory specified, and identify the dependencies between the jar files. The output will be xml representing the dependencies between two jar files.
I'm using IntelliJ Idea v11.4 and when I compile my project in the target/classes directory not only class files are listed but java files too. For every class file I find the corresponding java file...is this the right behaviour?
In my project I use maven to create the projects jar file and this jar file contains these java files too.
How can I prevent the java files from being copied in the jar file? I want to obfuscate the jar file to publish it in the net so if the java files are part of it too the obfuscation becomes useless.
Thanks for your help in advance!
Follow this guide:
You should build the Jar file using Build | Build Artifact menu item.
Note that by default all libraries are extracted to the target Jar. It became possible with addition of the new Extracted Directory element. Using such element you can extract a directory from a Jar file and place it into the output of your artifact: