import fs from "node:fs"; import child_process from "node:child_process"; type Properties = { "jar-file": string, "terminal"?: boolean, "minimum-mem"?: string, "maximum-mem"?: string } let jvm_properties: Properties = JSON.parse(fs.readFileSync("jvm-properties.json", { encoding: "utf8" })); if (jvm_properties["jar-file"] === undefined) throw new Error("`jar-file` is a required option."); if (jvm_properties["terminal"] === undefined) jvm_properties["terminal"] = false; if (jvm_properties["minimum-mem"] === undefined) jvm_properties["minimum-mem"] = "1G"; if (jvm_properties["maximum-mem"] === undefined) jvm_properties["maximum-mem"] = "4G"; let subprocess = child_process.spawn(jvm_properties["terminal"] ? "java" : "javaw", [`-Xms${ jvm_properties["minimum-mem"] }`, `-Xmx${ jvm_properties["maximum-mem"] }`, "-jar", jvm_properties["jar-file"]], { stdio: "ignore", detached: true, windowsHide: !jvm_properties["terminal"] } ); subprocess.unref();