Beispiel #1
0
        public static JavaInstance CreateInstance(Java java, RAMSettings settings)
        {
            JavaInstance instance = new JavaInstance();

            instance.settings  = settings;
            instance.java      = java;
            instance.arguments = new ArgumentInfo();
            return(instance);
        }
Beispiel #2
0
        public static void SearchJava()
        {
            javalist.Clear();
            Directory.CreateDirectory("OMCLC\\Plugins\\Data\\JavaSearcher.edgw100245");
            string filename = Path.Combine("OMCLC\\Plugins\\Data\\JavaSearcher.edgw100245", Guid.NewGuid().ToString() + ".txt");
            var    proc     = new Process();

            proc.StartInfo.FileName    = "OMCLC\\Libs\\JavaSearcher.exe";
            proc.StartInfo.Arguments   = filename;
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            proc.Start();
            proc.WaitForExit();
            foreach (var javaapp in File.ReadAllText(filename).Split('\n'))
            {
                if (javaapp.EndsWith("java.exe"))
                {
                    if (Path.GetDirectoryName(javaapp).IndexOf('\\') != -1)
                    {
                        if (File.Exists(Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(javaapp)), "release")))
                        {
                            foreach (var str in File.ReadAllLines(Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(javaapp)), "release")))
                            {
                                if (str.StartsWith("JAVA_VERSION="))
                                {
                                    string version = str.Replace("JAVA_VERSION=\"", "").Replace("\"", "");
                                    Java   java    = new Java();
                                    if (version.StartsWith("1.7"))
                                    {
                                        java.Version = 7;
                                    }
                                    else if (version.StartsWith("16."))
                                    {
                                        java.Version = 16;
                                    }
                                    else
                                    {
                                        java.Version = 8;
                                    }
                                    java.VersionString  = version;
                                    java.ExecutablePath = javaapp;
                                    javalist.Add(java);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            JArray arr = new JArray();

            foreach (var java in javalist)
            {
                arr.Add(java.ExecutablePath);
            }
            File.WriteAllText("OMCLC\\FirstLaunchInfo.json", arr.ToString());
        }
Beispiel #3
0
        public static void LoadFromProfile()
        {
            javalist.Clear();
            foreach (string javaapp in JArray.Parse(File.ReadAllText("OMCLC\\FirstLaunchInfo.json")))
            {
                if (javaapp.EndsWith("java.exe"))
                {
                    if (Path.GetDirectoryName(javaapp).IndexOf('\\') != -1)
                    {
                        if (File.Exists(Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(javaapp)), "release")))
                        {
                            foreach (var str in File.ReadAllLines(Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(javaapp)), "release")))
                            {
                                if (str.StartsWith("JAVA_VERSION="))
                                {
                                    string version = str.Replace("JAVA_VERSION=\"", "").Replace("\"", "");
                                    Java   java    = new Java();
                                    if (version.StartsWith("1.7"))
                                    {
                                        java.Version = 7;
                                    }
                                    else if (version.StartsWith("16."))
                                    {
                                        java.Version = 16;
                                    }
                                    else
                                    {
                                        java.Version = 8;
                                    }
                                    java.VersionString  = version;
                                    java.ExecutablePath = javaapp;
                                    javalist.Add(java);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            JArray arr = new JArray();

            foreach (var java in javalist)
            {
                arr.Add(java.ExecutablePath);
            }
            File.WriteAllText("OMCLC\\FirstLaunchInfo.json", arr.ToString());
        }
Beispiel #4
0
 public static JavaInstance CreateInstance(Java java, int maxRAM, int minRAM) => CreateInstance(java, RAMSettings.New(maxRAM, minRAM));
Beispiel #5
0
 public static JavaInstance CreateInstance(Java java) => CreateInstance(java, RAMSettings.None);