Right now, with the manifest file, I am able to create my runnable jar to work with:

folder structure:

libs/thirdpartylib1.jar
libs/thirdpartylib2.jar
myJar.jar

using this manifest:

Class-Path: libs/thirdpartylib1.jar libs/thirdpartylib2.jar
Main-Class: myPackage.myClass

Is there any way I can package these jar files into my runnable jar so that I do not need the libs/ directory in my folder structure for it to run?

Thanks in advance,

TW

Recommended Answers

All 6 Replies

Let me also add, with the 2 files inside the root of myJar.jar
&&
Class-Path: thirdpartylib1.jar thirdpartylib2.jar
in the manifest,

I still get the same problem. How do I tell it to look for those 2 .jars INSIDE myJar.jar instead of outside?

maybe not correct answer to your topic, but why not using for that some IDE (built-in funcioanlity),

Without the use of special class loaders, you can't put all of your jars into a single jar.

Is there a command-line tool that you might recommend that does this? The reason I don't use an IDE is because I'm compiling and packaging right from the command-line using bat and shell scripts.

hmmm, that's not good idea,

if you'll use a Netbeans, then you no longer needed any battery and scripts, its using same compilator as coming from JDK (linked as Java Platform), sure there you can define all JDK's which is instaled in Native OS, there you can directly link other project, or by click import package(s) or something built in *.jar file

different steps should be for Eclipse users, where you can compile with script or import plugin for Build, but compilator is custom

sure that's your decision, but why bother with something that does not..., sure I'm very very lazy ..., and my lazyness don't alowed me something similair :-)

in IDE you can add (I think that you are try to/using some obstrufator) this funkcionalitie too, just carrefully reads usages by autor(s)

maybe exists some cmd tool (but are for Dinosaurus Age for Java < 1.4) google ...

Here is one tool, but I've never used it personally:
http://one-jar.sourceforge.net/

It's not something that is generally done.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.