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.
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 ?
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!
> 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
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)