Class JavaLauncher

java.lang.Object
com.logicaldoc.util.exec.JavaLauncher

public class JavaLauncher extends Object
JavaLauncher Provides an easy way to launch java applications.
  • Constructor Details

    • JavaLauncher

      public JavaLauncher()
  • Method Details

    • exec

      public static Process exec(String mainClass, String classpath, String[] jvmargs, String[] properties) throws ExecException
      Launch a java program.
      Parameters:
      mainClass - - class with main method
      classpath - - the java classpath
      jvmargs - - arguments for the jvm
      properties - - any system properties
      Returns:
      the launched process
      Throws:
      ExecException - Error in executing the given command
    • execJar

      public static Process execJar(String pathToJar, String[] jvmargs) throws ExecException
      Execute a java jar file that contains a manifest.
      Parameters:
      pathToJar - - absolute path to your jar
      jvmargs - - arguments for the java virtual machine
      Returns:
      Process The launched process
      Throws:
      ExecException - An error happened during execution
    • findJVM

      public static String findJVM()
      Find a suitable JVM on the user's system.
      Returns:
      - path to java binary
    • main

      public static void main(String[] args)
      Demo - Launch a java program.
      Parameters:
      args - the invocation arguments