I have a simple class file with a main method. I would like to now create a jar file using Maven which also has all the jar's that it uses. I have even set up the Maven project and when I actually built it, it creates a jar file but I do not find any referenced libraries as part of that jar. How to acheive this?
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Even if the jar contained the other jars it's still not going to work like you think it will; you'd either need to include all the classes from the dependencies in the jar (i.e., unzip then add to the distribution jar's class directory hierarchy) or create a zip file distro which can be unzipped and run with the appropriate classpath set.
David Newton wrote:Why do you want a jar that contains other jars?
Maybe to make an executable jar that depends on library jars without having to explode them and merge them into the main jar classes?
There is, BTW a Maven plug-in to do exactly that. It's called something original like "Maven Executable JAR plugin" and its targets include both a jar that can be executed via the "java -jar" command and a more traditional JAR that can be included in a classpath.
An IDE is no substitute for an Intelligent Developer.