# eclipse-jarinjarloader **Repository Path**: mirrors_basilfx/eclipse-jarinjarloader ## Basic Information - **Project Name**: eclipse-jarinjarloader - **Description**: A custom classloader to be used from maven generated artifacts to allow executable jars and custom exclusion of some libraries at runtime (eg. swt libraries). Based on based on eclipse code and packing strategy. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2026-05-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # eclipse-jarinjarloader [![Download](https://api.bintray.com/packages/raisercostin/maven/eclipse-jarinjarloader/images/download.svg)](https://bintray.com/raisercostin/maven/eclipse-jarinjarloader/_latestVersion) ## Desciption A custom class loader based on eclipse code to allow executable jars and custom exclusion of some libraries at runtime. ## Features - All libraries are bundled inside jar as jars by maven. - Some libraries can be filtered out depending on the runtime operating system. The classloader to detect the type of OS and based on that to reconfigure the classpath according to the swt libraries specific to that OS. This question should provide support http://stackoverflow.com/questions/2706222/create-cross-platform-java-swt-application , http://mchr3k.github.io/swtjar/ ## How to use it See the [eclipse-jarinjarloader-swt-sample/pom.xml](https://github.com/raisercostin/eclipse-jarinjarloader/blob/master/eclipse-jarinjarloader-swt-sample/pom.xml) to see how to configure this. You will just need to change the properties for main class and the version of the jarinjarloader. 4.0.0 3.0.4 org.raisercostin eclipse-jarinjarloader-parent 1.3-SNAPSHOT eclipse-jarinjarloader-swt-sample jar 4.3 org.raisercostin.jarinjarloader.sample.JarInJarSwtMain ${project.version} org.apache.maven.plugins maven-dependency-plugin copy-dependencies prepare-package copy-dependencies ${project.build.directory}/classes/lib false false true runtime unpack prepare-package unpack org.raisercostin eclipse-jarinjarloader ${jarinjarloader.version} jar false ${project.build.directory}/classes org.apache.maven.plugins maven-jar-plugin true lib/ org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader ./ ${main.class} org.eclipse.swt.gtk.linux.x86 org.eclipse.swt.gtk.linux.x86_64 org.eclipse.swt.gtk.linux.x86_64 org.eclipse.swt.win32.win32.x86 org.eclipse.swt.win32.win32.x86 org.eclipse.swt.win32.win32.x86_64 org.eclipse.swt.win32.win32.x86_64 org.eclipse.swt.cocoa.macosx org.eclipse.swt.cocoa.macosx.x86_64 org.eclipse.swt ${swt.artifactId} ${swt.version} compile org.eclipse.swt org.eclipse.swt.win32.win32.x86 ${swt.version} runtime org.eclipse.swt org.eclipse.swt.win32.win32.x86_64 ${swt.version} runtime org.eclipse.swt org.eclipse.swt.cocoa.macosx.x86_64 ${swt.version} runtime org.eclipse.swt org.eclipse.swt.gtk.linux.x86 ${swt.version} runtime gtk_linux_x86 linux i386 org.eclipse.swt.gtk.linux.x86 gtk_linux_x86_64 linux x86_64 org.eclipse.swt.gtk.linux.x86_64 gtk_linux_amd64 linux amd64 org.eclipse.swt.gtk.linux.x86_64 win32_x86 windows x86 org.eclipse.swt.win32.win32.x86 win32_x86_64 windows x86_64 org.eclipse.swt.win32.win32.x86_64 win32_x86_amd64 windows amd64 org.eclipse.swt.win32.win32.x86_64 cocoa_macosx_x86 mac os x i386 org.eclipse.swt.cocoa.macosx cocoa_macosx_x86_64 mac os x x86_64 org.eclipse.swt.cocoa.macosx.x86_64 jcenter-bintray Bintray JCenter Maven Repository default https://jcenter.bintray.com/ true false ## How it works A classloader will serve classes from all the dependency libraries stored in lib folder in the jar. ## How to build and release mvn release:prepare release:perform -DskipTests=true -Prelease -Darguments="-DskipTests=true -Prelease" ## Credits - This code is based on eclipse jarinjar classloaders from [eclipse code](http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/plain/org.eclipse.jdt.ui/jar%20in%20jar%20loader/org/eclipse/jdt/internal/jarinjarloader/). - Based on [stackoverflow answer](http://stackoverflow.com/questions/1729054/including-dependencies-in-a-jar-with-maven). ## Other solutions Other similar techniques that don't work properly: - [springboot - executable jar](http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#executable-jar) - onejar - http://one-jar.sourceforge.net/ , https://code.google.com/archive/p/onejar-maven-plugin/ , - uberjar - http://fiji.sc/Uber-JAR - maven assembly jar-with-dependencies - shade - http://maven.apache.org/plugins/maven-shade-plugin/index.html - This plugin provides the capability to package the artifact in an uber-jar, including its dependencies and to shade - i.e. rename - the packages of some of the dependencies. - war - - proguard - http://www.alexeyshmalko.com/2014/proguard-real-world-example ``` There are three common methods for constructing an uber-JAR: Unshaded. Unpack all JAR files, then repack them into a single JAR. * Pro: Works with Java's default class loader. * Con: Files present in multiple JAR files with the same path (e.g., META-INF/services/javax.script.ScriptEngineFactory) will overwrite one another, resulting in faulty behavior. * Tools: Maven Assembly Plugin, Classworlds Uberjar Shaded. Same as unshaded, but rename (i.e., "shade") all packages of all dependencies. * Pro: Works with Java's default class loader. Avoids some (not all) dependency version clashes. * Con: Files present in multiple JAR files with the same path (e.g., META-INF/services/javax.script.ScriptEngineFactory) will overwrite one another, resulting in faulty behavior. * Tools: Maven Shade Plugin JAR of JARs. The final JAR file contains the other JAR files embedded within. * Pro: Avoids dependency version clashes. All resource files are preserved. * Con: Needs to bundle a special "bootstrap" classloader to enable Java to load classes from the wrapped JAR files. Debugging class loader issues becomes more complex. Tools: Eclipse JAR File Exporter, One-JAR. ```