Skip to content

fathzer/java-check-launcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Central License Quality Gate Status javadoc

java-check-launcher

A java application launcher that checks if used JRE is compatible with a launched application.

How to use it?

This library requires Java 1.2+.

1 - Add The library to your project. Add the following dependency to your project.

<dependency>
  <groupId>com.fathzer</groupId>
  <artifactId>java-check-launcher</artifactId>
  <version>1.0.1</version>
</dependency>

2 - Create settings resources. Create a resource file in com/fathzer/java-check-launcher/settings.properties with the following content:

min.java.version=1.8
main.class=com.me.MyApp
logger=swing

Replace the min.java.version value with the minimum java version required by your application and main.class value by the name of your main class.
logger is optional. If your application is a Swing application, leave the line, if it is a console application, remove the line.
You can also implement your own logger. Be aware that this class will be instantiated before checking whether running JRE is recent enough. So it is wise to compile your custom logger for java 1.2.

3 - Launch the application. Run the command java com.fathzer.launcher.Launcher arg1 arg2 (Here, arg1 and arg2 are examples, assuming that the launched application requires two arguments. If your application requires no arguments, just run java com.fathzer.launcher.Launcher).
The launcher will check the java version and will display a comprehensive message if application is not compatible with installed java version (not the usual unsupported class file major version exception). If the java version is not supported, the process exits with a -1 code. If an error occurs (for instance if settings are invalid), the process exits with a -2 code.
If everything is ok, the arguments are passed to the application's main method.

How to localize the alert messages when application can't be launched?

This library emits warnings in English. They are read from the com/fathzer/launcher/Resources ResourceBundle.
If you want, for instance, add French translations, you have to add a your a com/fathzer/launcher/Resources_fr.properties containing those translations to your application's resources.

How to compile it?

Recent Java JDK are not able to compile anymore java 1.2 code. You should use a Java 8 JDK.

For instance, if you have toolchains configured in ~/.m2/toolchains.xml, you can run the command mvn -Djdk=8 clean compile.

Another cool option, if you have Docker installed, you can use the following command (on Linux) to deploy the library:

docker run --rm -v $(pwd):/app -v ~/.m2:/root/.m2 -v ~/.gnupg:/root/.gnupg -e GPG_TTY=/dev/console -w /app maven:3.6.3-jdk-8 mvn clean deploy -Dgpg.passphrase="passphrase"

Where passphrase is the passphrase of the GPG key used to sign the artifact.

About

A java application launcher that checks if used JRE is compatible with launched application

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages