diff --git a/.idea/misc.xml b/.idea/misc.xml
index ec7da81..ad08689 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -4,7 +4,7 @@
-
+
\ No newline at end of file
diff --git a/src/main/java/tech/nevets/jaml/Config.java b/src/main/java/tech/nevets/jaml/Config.java
index ca418fc..7918a98 100644
--- a/src/main/java/tech/nevets/jaml/Config.java
+++ b/src/main/java/tech/nevets/jaml/Config.java
@@ -5,10 +5,10 @@ import org.simpleyaml.configuration.file.YamlFile;
import java.io.IOException;
public class Config {
- private static final YamlFile YML_FILE = new YamlFile(JAML.path + "\\config.yml");
+ private static final YamlFile YML_FILE = new YamlFile(JAML.path + "/config.yml");
public static void loadConfig() {
- YML_FILE.setConfigurationFile(JAML.path + "\\config.yml");
+ YML_FILE.setConfigurationFile(JAML.path + "/config.yml");
try {
if (!YML_FILE.exists()) {
System.out.println("Config file not found, creating new one...");
@@ -49,7 +49,7 @@ public class Config {
YML_FILE.addDefault("java.jdk16", "");
YML_FILE.addDefault("java.jdk17", "");
YML_FILE.addDefault("game.show-snapshots", false);
- YML_FILE.addDefault("launcher.default-profile", "default");
+ YML_FILE.addDefault("launcher.default-profile", "");
YML_FILE.setComment("launcher.default-profile", "Set's the profile that will be loaded automatically");
YML_FILE.addDefault("launcher.path","default");
YML_FILE.setComment("launcher.path","Path to JAML files\n" + "default: " + JAML.path.toString());
@@ -92,5 +92,6 @@ public class Config {
public static void setValue(String path, Object data) {
YML_FILE.set(path, data);
+ saveConfig();
}
}
\ No newline at end of file
diff --git a/src/main/java/tech/nevets/jaml/gui/NewProfileGui.java b/src/main/java/tech/nevets/jaml/gui/NewProfileGui.java
index 170e4f8..167d686 100644
--- a/src/main/java/tech/nevets/jaml/gui/NewProfileGui.java
+++ b/src/main/java/tech/nevets/jaml/gui/NewProfileGui.java
@@ -1,5 +1,6 @@
package tech.nevets.jaml.gui;
+import tech.nevets.jaml.Config;
import tech.nevets.jaml.objects.Profile;
import tech.nevets.jaml.objects.Version;
import tech.nevets.jaml.util.LoaderUtils;
@@ -141,6 +142,11 @@ public class NewProfileGui extends JFrame {
}
ProfileUtils.getProfileList();
+ if (ProfileUtils.activeProfile == null) {
+ Config.setValue("launcher.default-profile", profile.getProfileName());
+ ProfileUtils.getActiveProfile();
+ }
+
this.dispose();
});
contentPane.add(button);
diff --git a/src/main/java/tech/nevets/jaml/gui/StartupGui.java b/src/main/java/tech/nevets/jaml/gui/StartupGui.java
index 19ef76d..98af776 100644
--- a/src/main/java/tech/nevets/jaml/gui/StartupGui.java
+++ b/src/main/java/tech/nevets/jaml/gui/StartupGui.java
@@ -92,7 +92,9 @@ public class StartupGui extends JFrame {
currentTaskLabel.setText("Loading Active Profile...");
task++;
- ProfileUtils.getActiveProfile();
+ if (ProfileUtils.activeProfile != null) {
+ ProfileUtils.getActiveProfile();
+ }
smoothIncrease();
currentTaskLabel.setText("Getting Game Loaders...");
diff --git a/src/main/java/tech/nevets/jaml/util/JREDetector.java b/src/main/java/tech/nevets/jaml/util/JREDetector.java
new file mode 100644
index 0000000..d49eaa8
--- /dev/null
+++ b/src/main/java/tech/nevets/jaml/util/JREDetector.java
@@ -0,0 +1,48 @@
+package tech.nevets.jaml.util;
+
+import tech.nevets.jaml.Config;
+import tech.nevets.jaml.Launcher;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+public class JREDetector {
+
+ public static void main(String[] args) {
+ try {
+ findJavaVersion();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void findJavaVersion() throws IOException {
+ String javaHomePath = System.getenv("JAVA_HOME");
+
+ if (javaHomePath == null) {
+ System.out.println("No java path found");
+ return;
+ }
+
+ ProcessBuilder processBuilder = new ProcessBuilder();
+ processBuilder.command(javaHomePath + "/bin/java.exe", "--version");
+ Process process = processBuilder.start();
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
+ String line = "";
+ while ((line = reader.readLine()) != null) {
+ if (line.contains("18")) {
+ return;
+ } else if (line.contains("17")) {
+ Config.setValue("java.jdk17", javaHomePath + "/bin");
+ } else if (line.contains("16")) {
+ Config.setValue("java.jdk16", javaHomePath + "/bin");
+ } else if (line.contains("8")) {
+ Config.setValue("java.jdk8", javaHomePath + "/bin");
+ }
+ }
+
+ process.destroy();
+ }
+}