Skip to content

Instantly share code, notes, and snippets.

@alksily
Created March 1, 2019 12:27
Show Gist options
  • Save alksily/f93a98309854378c57b69bb7025ae86c to your computer and use it in GitHub Desktop.
Save alksily/f93a98309854378c57b69bb7025ae86c to your computer and use it in GitHub Desktop.
Launch frame
float f = (float) (Runtime.getRuntime().maxMemory() / 1024L / 1024L);
if(f > MIN_HEAP){
LauncherFrame.main(args);
}else{
try{
ArrayList<String> localArrayList = new ArrayList<String>();
String str = TGMMain.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
if(OperationSystem.getPlatform().equals(OperationSystem.OS.WINDOWS)){
localArrayList.add("javaw");
}else{
localArrayList.add("java");
}
localArrayList.add("-Xms" + MIN_HEAP + "m");
localArrayList.add("-Xmx" + RECOMMENDED_HEAP + "m");
if(Runtime.getRuntime().availableProcessors() >= 2){
localArrayList.add("-XX:ParallelGCThreads=2");
}
localArrayList.add("-classpath");
localArrayList.add(str);
localArrayList.add("ru.aengine.tgm.launcher.LauncherFrame");
ProcessBuilder localProcessBuilder = new ProcessBuilder(localArrayList);
Process localProcess = localProcessBuilder.start();
if (localProcess == null) throw new Exception("!");
System.exit(0);
}catch(URISyntaxException e){
e.printStackTrace();
LauncherFrame.main(args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment