@Test public void simple() throws Throwable { String main = java("com.example.Hello", new String[] { "public class Hello {", " public static void main(String[] args) {", " System.out.println(\"Hello, launcher!\");", " assertThat(Arrays.asList(args), empty());", " }", "}", }); File script = script(main); Launcher.main(script.getAbsolutePath()); }
public static void main(String... args) throws Throwable { if (args.length != 1) { throw new LauncherException("Usage: java -jar <this.jar> /path/to/launch-script.properties"); } File script = new File(args[0]); Properties properties = new Properties(); try (InputStream input = new BufferedInputStream(new FileInputStream(script))) { properties.load(input); } catch (IOException e) { throw new LauncherException(MessageFormat.format( "exception occurred while loading launch script: {0}", script), e); } launch(properties); }
Launcher { public static void main(String... args) throws Throwable { if (args.length != 1) { throw new LauncherException("Usage: java -jar <this.jar> /path/to/launch-script.properties"); } File script = new File(args[0]); Properties properties = new Properties(); try (InputStream input = new BufferedInputStream(new FileInputStream(script))) { properties.load(input); } catch (IOException e) { throw new LauncherException(MessageFormat.format( "exception occurred while loading launch script: {0}", script), e); } launch(properties); } }
Launcher { public static void main(String... args) throws Throwable { if (args.length != 1) { throw new LauncherException("Usage: java -jar <this.jar> /path/to/launch-script.properties"); } File script = new File(args[0]); Properties properties = new Properties(); try (InputStream input = new BufferedInputStream(new FileInputStream(script))) { properties.load(input); } catch (IOException e) { throw new LauncherException(MessageFormat.format( "exception occurred while loading launch script: {0}", script), e); } launch(properties); } private  Launcher(); }
Launcher { public static void main(String... args) throws Throwable { if (args.length != 1) { throw new LauncherException("Usage: java -jar <this.jar> /path/to/launch-script.properties"); } File script = new File(args[0]); Properties properties = new Properties(); try (InputStream input = new BufferedInputStream(new FileInputStream(script))) { properties.load(input); } catch (IOException e) { throw new LauncherException(MessageFormat.format( "exception occurred while loading launch script: {0}", script), e); } launch(properties); } private  Launcher(); static void main(String... args); static void launch(Properties properties); static void launch(List<File> classpath, String mainClass, List<String> arguments); }
Launcher { public static void main(String... args) throws Throwable { if (args.length != 1) { throw new LauncherException("Usage: java -jar <this.jar> /path/to/launch-script.properties"); } File script = new File(args[0]); Properties properties = new Properties(); try (InputStream input = new BufferedInputStream(new FileInputStream(script))) { properties.load(input); } catch (IOException e) { throw new LauncherException(MessageFormat.format( "exception occurred while loading launch script: {0}", script), e); } launch(properties); } private  Launcher(); static void main(String... args); static void launch(Properties properties); static void launch(List<File> classpath, String mainClass, List<String> arguments);  }