2

How can I add a custom loader to the executable jar? At the moment i'm doing it manually by opening the jar file, pasting the class and re-signing it the end. -.-

Thanks in advance, Pedro Silva

1 Answer 1

1

Executable jar restrictions

There are 2 types of restrictions that you need to consider when working with a Spring Boot Loader packaged application.

Zip entry compression

The ZipEntry for a nested jar must be saved using the ZipEntry.STORED method. This is required so that we can seek directly to individual content within the nested jar. The content of the nested jar file itself can still be compressed, as can any other entries in the outer jar.

System ClassLoader

Launched applications should use Thread.getContextClassLoader() when loading classes (most libraries and frameworks will do this by default). Trying to load nested jar classes via ClassLoader.getSystemClassLoader() will fail. Please be aware that java.util.Logging always uses the system classloader, for this reason you should consider a different logging implementation.

Alternative single jar solutions

If the above restrictions mean that you cannot use Spring Boot Loader the following alternatives could be considered:

  1. Maven Shade Plugin
  2. JarClassLoader
  3. OneJar

Resource Link:

  1. The executable jar format
  2. spring boot loading jars (application dependencies and external file system jars)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.