https://github.com/fathzer/java-check-launcher
A java application launcher that checks if used JRE is compatible with launched application
https://github.com/fathzer/java-check-launcher
Last synced: 6 months ago
JSON representation
A java application launcher that checks if used JRE is compatible with launched application
- Host: GitHub
- URL: https://github.com/fathzer/java-check-launcher
- Owner: fathzer
- License: apache-2.0
- Created: 2024-06-02T08:23:09.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-11-03T17:40:12.000Z (8 months ago)
- Last Synced: 2025-11-03T18:30:00.595Z (8 months ago)
- Language: Java
- Size: 112 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://central.sonatype.com/artifact/com.fathzer/java-check-launcher)
[](https://github.com/fathzer/java-check-launcher/blob/master/LICENSE)
[](https://sonarcloud.io/summary/new_code?id=fathzer_java-check-launcher)
[](https://javadoc.io/doc/com.fathzer/java-check-launcher)
# 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.
```xml
com.fathzer
java-check-launcher
1.0.1
```
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](https://github.com/fathzer/java-check-launcher/blob/src/main/java/com.fathzer.launcher.Logger.java). 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](https://maven.apache.org/guides/mini/guide-using-toolchains.html) 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:
```bash
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.