Packing Java Project Library Packages Into A Jar File
I just decompress the library jars into my jar, in order to get .class files just as they were my own code.
This approach is probably not universal, and may not work in some cases, for example it's to be seen if this works also with classes that are encrypted in the jar. But it's general enough to be considered useful in many, probably most, cases.
Basically what we can do is to decompress each library file and include its files in our jars, in order to look just like follows:
+- com +- org +- test +- package .... - myclassfile1.class - myclassfile2.class - ... +- META-INF - MANIFEST.MF +- org +- apache +- poi +- uncompressed package path - LibraryClassFile1.class - LibrarayClassFile2.class - ... +- another uncompressed package path - LibarayClassFile3.class - LibrarayClassFile4.class - ...
In this way when the JVM runs your program, the referenced libraries will be automatically in the classpath, exactly as they were code written and compiled by you. The library code is basically merged into yours and (from the JVM's standpoint) completely indistinguishable.