What are auto executable jars?

68
May 08, 2019, at 1:30 PM

I was going through spring-boot-maven-plugin documentation and came across a term auto executable jar.

Could someone please explain me what is an auto executable jar and how is it different then normal jar files and how they are auto executed?

spring-boot-maven-plugin documentation mentions the term but does not go further to explain it

repackage: create a jar or war file that is auto-executable. It can replace the regular artifact or can be attached to the build lifecycle with a separate classifier.

Answer 1
Could someone please explain me what is an auto executable jar

A fully executable jar can be executed like any other executable binary or it can be registered with init.d or systemd. This makes it very easy to install and manage Spring Boot applications in common production environments.

So In conclusion is like any other executable when you use a executable jar

how is it different then normal jar files and how they are auto executed?

Well a java file you need to run with java -jar

From Spring Docs

Answer 2

The Maven build of a Springboot application first build your own application and pack it into a JAR file.

In the second stage (repackage) it will wrap that jar with all the jar files from the dependency tree into a new wrapper jar archive. It will also generate a Manifest file where is defined what's the application Main class is (also in the wrapper jar).

After mvn package you can also see 2 jar files in your target directory. The original file and the wrapped jar file.

You can start a Springboot application with a simple command like:

java -jar my-springboot-app.jar
Answer 3

I may suggest that auto executable means that you supplied main method so that it can be launched with java -jar options, otherwise it may be just a java library. Here is a quote from https://docs.spring.io/spring-boot/docs/current/maven-plugin/repackage-mojo.html

Repackages existing JAR and WAR archives so that they can be executed from the command line using java -jar. With layout=NONE can also be used simply to package a JAR with nested dependencies (and no main class, so not executable).

Answer 4
  • Executable jar - the one that has main class declared in manifest and can be run with java -jar yourJarFile.jar command
  • Other jars - jars jars without delcared main calss. Can be anything - application, library, etc. Still can run application by providing fully.qualified.class.name as entry point like java -cp yourJarFile.jar my.bootstrap.BootstrapClass
  • Autoexecutable jars - never heard about it :)
READ ALSO
How to reboot the windows service using CMD? [on hold]

How to reboot the windows service using CMD? [on hold]

I'm Creating java program and deploy Windows service using procrunNow i need to restart that service via CMD Line

45
How to make chrome driver or gecko driver undetectable? cdc and navigator

How to make chrome driver or gecko driver undetectable? cdc and navigator

I'm trying to test this page but it's got passive google recaptcha 3 on it, and it detects webdriversI saw some posts about changing the name of the cdc variable, and also making the navigator

144
Twitter bot, java, Heroku. “State changed from up to crashed”

Twitter bot, java, Heroku. “State changed from up to crashed”

I have a simple Java Twitter bot built with twitter4jI just need to have one Java class that runs nonstop and it should all be well

58