how can i put jars dependency into my main jar?

Mine:

Plataform : Windows XP 2SP (yes, i磎 newbie)

JDK: 6

IDE: Eclipse 3.2

External Framework :JMF

Ok, I磎 doing a multimedia project (using RTP to transfer data) and I saw that the Sun had a framework called JMF 2.1 (that was uncontinued) and I decide to learn how this "framework works", I study the architecture, the main classes (almost all) and so.

Then I download the .zip (all plataform), unzip and create a folder structure.

And the jars are on the ..\jmf-2_1_1e-alljava\JMF-2.1.1e\lib.

Right!!!

So I start a new project (java project) on the eclipse 3.2, and I choose all this jar like a external jars. Realy I made a player that works, but when I try to generate a single file .jar, the eclipse generate a file with the 32K, I want to know how can I create a single .jar with all depency (no matter size)?

It磗 just to run this application without need to set a CLASSPATH or file build. I want to generate a single .jar (with 4MB or more) and execute in any machine ( with jdk) java -jar myapp.jar and it works, it is possible ? How can I do this with the eclipse ?

And thanks by you reading this.

[1178 byte] By [dreampeppers99a] at [2007-11-27 3:36:58]
# 1
The jar tutorial: http://java.sun.com/docs/books/tutorial/deployment/jar/Read the bit about manifests.
DrClapa at 2007-7-12 8:40:14 > top of Java-index,Java Essentials,New To Java...
# 2
Another symplest way ?I think that was just import, or add external lib.. but doesnt work, how can I generate a only jar (Export on eclipse) that contais all jar depency?thanks a lot
dreampeppers99a at 2007-7-12 8:40:14 > top of Java-index,Java Essentials,New To Java...
# 3
Could be like the web app with the folder lib, and generate one war.Can It works on commom applications ?
dreampeppers99a at 2007-7-12 8:40:14 > top of Java-index,Java Essentials,New To Java...
# 4
Only way to create a single jar containing all dependencies is to unpack all dependent jars and repack their content inside your own jar.Nested jars are not supported.
jwentinga at 2007-7-12 8:40:14 > top of Java-index,Java Essentials,New To Java...
# 5

Why can I just ....

First open the file (jar) with a software (zip), and create a folder on root named lib. Copy all jars (dependency jar JMF) to inside this folder (lib).

And just update the file MANIFEST.MF

Class-Path: lib/jmf.jar lib/jmfRTP.jar

This doesnt solve the problem? Why?

Here on site says no: (Note: The Class-Path ...)

http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html

Why ?

dreampeppers99a at 2007-7-12 8:40:14 > top of Java-index,Java Essentials,New To Java...
# 6

There are ways to do this, such as writing your own classloader to load the dependencies from within the jar (not easy), or finding a package that already does just that, like fatjar. But why would you? Suppose you find a bug in one of the dependencies, and need a newer version? You then have to re-package your enormo-jar, and re-distribute and re-deploy it, rather than just advise that the newer dependency is installed. Modular software is good, and bundling all your dependencies into one jar is anathema to this. In short, don't bother!

georgemca at 2007-7-12 8:40:14 > top of Java-index,Java Essentials,New To Java...
# 7
Georgemc I know the modular software is good... But in this question I need it. Thanks a lot.
dreampeppers99a at 2007-7-12 8:40:14 > top of Java-index,Java Essentials,New To Java...
# 8

> Georgemc I know the modular software is good... But

> in this question I need it. Thanks a lot.

If you really really think it's a good idea, have a look for an Eclipse plugin called FatJar. It gives you a wizard to do this, and will also generate an Ant script for doing it

georgemca at 2007-7-12 8:40:14 > top of Java-index,Java Essentials,New To Java...
# 9

Georgemc thanks I磎 lookin now FatJar (what name).

But you think that is will solve my problem without a new problem?

Take a look, i磎 working with the JMF and Eclipse, "my" JDK is the 1.6.

I create a project and set Externals jar (all of framework JMF).

I cant test this now, Im using a pc 128Mb with no java.... nothing . I wait to arrive at my house.

Thanks a lot.

(sorry for my bad english)

dreampeppers99a at 2007-7-12 8:40:14 > top of Java-index,Java Essentials,New To Java...
# 10
> Georgemc I know the modular software is good... But> in this question I need it. Thanks a lot.there are indeed such situations (had one a few months ago). Repackaging the dependencies is usually the best way in such cases (but do take care with license issues).
jwentinga at 2007-7-12 8:40:14 > top of Java-index,Java Essentials,New To Java...