I would like to build a Jar whose main class package is not at the root of the jar.
In the application, I’ve just written a Main class
com.gmail.bernabe.laurent.test.HelloWorld
I could simply make a Runnable jar from the Eclipse IDE, but I would like to go a step further
=> Having the final jar organized like this
Root
=> META-INF
=> Lib
=====> com
==========> gmail
…
Instead of :
Root
=> META-INF
==> com
======> gmail
…
Is it possible to configure the Manifest file so that the Jar runs properly ?
Thanks in advance
Why do I want to do this ?
I want to build a JOGL-based jar organized as follow
=> JOGL (subdirectories are JOGL just needed files)
=> CORE (subdirectorie is the core application package)
=> LAUNCHER (subdirectory is the custom classloader package)
=> META-INF
Yes and no.
No, because you should not do that: imagine someone supporting your code. Or even yourself, two years later, returning to the project: you saw hundreds of jars organised as defined by
JarClassLoader, you worked in tens of “usual” projects… Now, well, now you see a JAR file. Will you expect it to have a tricky custom loading scheme? I doubt so.Yes, because you can add one more main class, use it to set up a classloader, and after that load classes from any layout. You will need to keep manifest and the startup class at the “proper” places, though.
The tutorial on class loading can be found at http://java.sun.com/developer/onlineTraining/Security/Fundamentals/magercises/ClassLoader/help.html