mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-14 07:05:40 -04:00
Tools.java: Add a global method to launch JVM with additional args
This commit is contained in:
parent
7c0f688f89
commit
e8a972c0ba
@ -64,26 +64,8 @@ public class InstallModActivity extends LoggableActivity {
|
||||
new Thread(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
final int exitCode = launchJavaRuntime(modFile, javaArgs);
|
||||
launchJavaRuntime(modFile, javaArgs);
|
||||
IS_JRE_RUNNING = false;
|
||||
|
||||
appendlnToLog("Java Exit code: " + exitCode);
|
||||
|
||||
runOnUiThread(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(InstallModActivity.this);
|
||||
dialog.setMessage(getString(R.string.mcn_exit_title, exitCode));
|
||||
dialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2){
|
||||
MainActivity.fullyExit();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "JREMainThread").start();
|
||||
} catch (Throwable th) {
|
||||
@ -104,15 +86,10 @@ public class InstallModActivity extends LoggableActivity {
|
||||
// mIsResuming = true;
|
||||
}
|
||||
|
||||
private int launchJavaRuntime(File modFile, String javaArgs) {
|
||||
private void launchJavaRuntime(File modFile, String javaArgs) {
|
||||
try {
|
||||
JREUtils.relocateLibPath(this);
|
||||
|
||||
List<String> javaArgList = new ArrayList<String>();
|
||||
javaArgList.add(Tools.homeJreDir + "/bin/java");
|
||||
|
||||
Tools.getJavaArgs(this, javaArgList);
|
||||
|
||||
|
||||
File cacioAwtLibPath = new File(Tools.MAIN_PATH, "cacioawtlib");
|
||||
if (cacioAwtLibPath.exists()) {
|
||||
StringBuilder libStr = new StringBuilder();
|
||||
@ -138,17 +115,11 @@ public class InstallModActivity extends LoggableActivity {
|
||||
javaArgList.add(modFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
System.out.println(Arrays.toString(javaArgList.toArray(new String[0])));
|
||||
// System.out.println(Arrays.toString(javaArgList.toArray(new String[0])));
|
||||
|
||||
//JREUtils.redirectStdio(false);
|
||||
JREUtils.setJavaEnvironment(this);
|
||||
JREUtils.initJavaRuntime();
|
||||
JREUtils.chdir(Tools.MAIN_PATH);
|
||||
|
||||
return VMLauncher.launchJVM(javaArgList.toArray(new String[0]));
|
||||
Tools.launchJavaVM(this, javaArgList);
|
||||
} catch (Throwable th) {
|
||||
Tools.showError(this, th, true);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,40 +70,31 @@ public final class Tools
|
||||
public static ShellProcessOperation mLaunchShell;
|
||||
private static int exitCode = 0;
|
||||
public static void launchMinecraft(final LoggableActivity ctx, MCProfile.Builder profile, JMinecraftVersionList.Version versionInfo) throws Throwable {
|
||||
JREUtils.relocateLibPath(ctx);
|
||||
String[] launchArgs = getMinecraftArgs(profile, versionInfo);
|
||||
|
||||
List<String> javaArgList = new ArrayList<String>();
|
||||
/*
|
||||
if (LAUNCH_TYPE == LTYPE_PROCESS || LAUNCH_TYPE == LTYPE_BINARYEXEC) javaArgList.add(Tools.homeJreDir + "/bin/java");
|
||||
else javaArgList.add("java");
|
||||
*/
|
||||
javaArgList.add(Tools.homeJreDir + "/bin/java");
|
||||
|
||||
String launchClassPath = generateLaunchClassPath(profile.getVersion());
|
||||
System.out.println("Java Classpath: " + launchClassPath);
|
||||
|
||||
getJavaArgs(ctx, javaArgList);
|
||||
|
||||
List<String> javaArgList = new ArrayList<String>();
|
||||
|
||||
javaArgList.add("-cp");
|
||||
/*
|
||||
if (versionInfo.mainClass.equals("net.minecraft.launchwrapper.Launch")) {
|
||||
// Also preload LWJGL3 to fix crash on send input events
|
||||
javaArgList.add(Tools.MAIN_PATH + "/lwjgl3/ClassWrapper.jar:" + getLWJGL3ClassPath());
|
||||
javaArgList.add("ClassWrapper");
|
||||
javaArgList.add(launchClassPath);
|
||||
} else { */
|
||||
javaArgList.add(getLWJGL3ClassPath() + ":" + launchClassPath);
|
||||
// }
|
||||
|
||||
javaArgList.add(versionInfo.mainClass);
|
||||
javaArgList.addAll(Arrays.asList(launchArgs));
|
||||
|
||||
// can fix java?
|
||||
// setEnvironment("ORIGIN", Tools.homeJreDir + "/lib");
|
||||
|
||||
launchJavaVM(ctx, javaArgList);
|
||||
}
|
||||
|
||||
public static void launchJavaVM(final LoggableActivity ctx, final List<String> args) throws Throwable {
|
||||
JREUtils.relocateLibPath(ctx);
|
||||
|
||||
List<String> javaArgList = new ArrayList<String>();
|
||||
javaArgList.add(Tools.homeJreDir + "/bin/java");
|
||||
getJavaArgs(ctx, javaArgList);
|
||||
javaArgList.addAll(args);
|
||||
|
||||
JREUtils.setJavaEnvironment(ctx);
|
||||
|
||||
JREUtils.initJavaRuntime();
|
||||
JREUtils.chdir(Tools.MAIN_PATH);
|
||||
|
||||
@ -113,9 +104,6 @@ public final class Tools
|
||||
|
||||
exitCode = VMLauncher.launchJVM(javaArgList.toArray(new String[0]));
|
||||
ctx.appendlnToLog("Java Exit code: " + exitCode);
|
||||
|
||||
|
||||
|
||||
ctx.runOnUiThread(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user