Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

AppLauncher use cases


    1  Use cases
    2  Example
    3  See also

The AppLauncher class launch a process to start a Java jar file. You can:

This class allows to:
  • Specify the module paths (the --add-modules declaration)
  • Specify the --add-opens declarations
  • Specify the --add-exports declarations
  • Specify the required Java version
  • Specify the allowed custom properties
  • Specify the path of the main Class
The class allows to start a new process with a specified JVM (not necessarily the current JVM used to execute the AppLauncher program) with customized arguments specified in a configuration file:
applauncher
This class and all its dependencies is on the AppLauncher.jar package. It has no dependencies on other packages.

Use cases

The AppLauncher class and all its dependencies is on the AppLauncher.jar package. It has no dependencies on other packages.

It means that you can use it with almost any JVM. the configuration of this class will allow you to start any program, even on a much more recent JVM.

The best way to use it is to create a jar file (with a manifest) to be able to execute the launcher by double clicking on the jar file, and use it to start your program.

Example

Suppose that you want to execute a Java program using JavaFX, working with a JDK greater or equal than Java 17.

You will have the following code in the launcher:
   public class MyAppLauncher extends AppLauncher {
      public AppLauncher(String[] args) {
        super(args);
      }  
      
      public static void main(String[] args) {
        MyAppLauncher launcher = new MyAppLauncher(args);
        launcher.setAddModules("javafx.controls,javafx.fxml,javafx.graphics,javafx.swing,javafx.web");
        launcher.setAddOpensAllUnnamed("javafx.web/javafx.scene.web", "javafx.web/com.sun.webkit");
        launcher.requireJavaVersion("17-");
        launcher.start();
      }      
          
      @Override
      protected String getLaunchable() {
        return "MyApplication.jar";
      }

      @Override
      protected String getConfigurationFile() {
        return "confFile.conf";
      }  
   }
And the following code in the confFile.conf file:
   JAVAHOME=L:\WRK\Java\Tools\jdk-17.0.2
   JAVAFXLIB=L:\WRK\Java\Tools\javafx17\lib

See also


Categories: lang.applauncher | packages

Copyright 2006-2024 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences