fix #580
This commit is contained in:
parent
42591b72c3
commit
bcd47df4a7
|
@ -176,7 +176,10 @@ class MainActivity : FCLActivity(), OnSelectListener, View.OnClickListener {
|
||||||
.setView(layout)
|
.setView(layout)
|
||||||
.setPositiveButton(com.tungsten.fcllibrary.R.string.dialog_positive) { _: DialogInterface?, _: Int ->
|
.setPositiveButton(com.tungsten.fcllibrary.R.string.dialog_positive) { _: DialogInterface?, _: Int ->
|
||||||
JarExecutorHelper.exec(
|
JarExecutorHelper.exec(
|
||||||
this@MainActivity, null, 8, editText.text.toString()
|
this@MainActivity,
|
||||||
|
null,
|
||||||
|
JarExecutorHelper.getJava(null),
|
||||||
|
editText.text.toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.setNegativeButton(com.tungsten.fcllibrary.R.string.dialog_negative, null)
|
.setNegativeButton(com.tungsten.fcllibrary.R.string.dialog_negative, null)
|
||||||
|
|
|
@ -59,16 +59,7 @@ public class JarExecutorHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void launchJarExecutor(Context context, File file) {
|
private static void launchJarExecutor(Context context, File file) {
|
||||||
int version = getJavaVersion(file);
|
exec(context, file, getJava(file), null);
|
||||||
int javaVersion = getNearestJavaVersion(version);
|
|
||||||
Profile profile = Profiles.getSelectedProfile();
|
|
||||||
if (profile != null) {
|
|
||||||
String java = profile.getGlobal().getJava();
|
|
||||||
if (!java.equals(JavaVersion.JAVA_AUTO.getVersionName())) {
|
|
||||||
javaVersion = JavaVersion.getJavaFromVersionName(java).getVersion();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exec(context, file, javaVersion, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void exec(Context context, File file, int javaVersion, String args) {
|
public static void exec(Context context, File file, int javaVersion, String args) {
|
||||||
|
@ -90,6 +81,22 @@ public class JarExecutorHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getJava(File file) {
|
||||||
|
int javaVersion = JavaVersion.JAVA_VERSION_8;
|
||||||
|
if (file != null) {
|
||||||
|
int version = getJavaVersion(file);
|
||||||
|
javaVersion = getNearestJavaVersion(version);
|
||||||
|
}
|
||||||
|
Profile profile = Profiles.getSelectedProfile();
|
||||||
|
if (profile != null) {
|
||||||
|
String java = profile.getGlobal().getJava();
|
||||||
|
if (!java.equals(JavaVersion.JAVA_AUTO.getVersionName())) {
|
||||||
|
javaVersion = JavaVersion.getJavaFromVersionName(java).getVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return javaVersion;
|
||||||
|
}
|
||||||
|
|
||||||
private static int getNearestJavaVersion(int majorVersion) {
|
private static int getNearestJavaVersion(int majorVersion) {
|
||||||
if (majorVersion > JavaVersion.JAVA_VERSION_17)
|
if (majorVersion > JavaVersion.JAVA_VERSION_17)
|
||||||
return JavaVersion.JAVA_VERSION_21;
|
return JavaVersion.JAVA_VERSION_21;
|
||||||
|
@ -135,6 +142,7 @@ public class JarExecutorHelper {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int classVersionToJavaVersion(int majorVersion) {
|
private static int classVersionToJavaVersion(int majorVersion) {
|
||||||
if (majorVersion < 46)
|
if (majorVersion < 46)
|
||||||
return 2;
|
return 2;
|
||||||
|
|
Loading…
Reference in New Issue