Packing Java Project Library Packages Into A Jar File

             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
      - ...
  +- 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.


Post a Comment

Popular posts from this blog

Conversion from Clob To String in java and Vice versa

Portable Java 8/ JDK8 setup without admin rights

Multi Threading , Producer consumer problem in Java