我正在尝试用 Java 运行 Minecraft.jar(游戏)。我尝试使用以下代码运行它:
String LibsAndStuff = String.format(
"%s/minecraft.jar:%s/lwjgl.jar:%s/lwjgl_util.jar:%s/jinput.jar",
OSDetector.getMinecraftJarDiretoryFullPath(),
OSDetector.getMinecraftJarDiretoryFullPath(),
OSDetector.getMinecraftJarDiretoryFullPath(),
OSDetector.getMinecraftJarDiretoryFullPath());
ProcessBuilder pb = new ProcessBuilder("java", "-Xmx2048M", "-Xms512M", "-cp",
LibsAndStuff, String.format("-Djava.library.path=%s/natives",
OSDetector.getMinecraftJarDiretoryFullPath()),
"net.minecraft.client.Minecraft");
pb.directory(new File(OSDetector.getMinecraftJarDiretoryFullPath()));
try {
Process p = pb.start();
} catch (IOException e1) {
e1.printStackTrace();
}
OSDetector.getMinecraftJarDiretoryFullPath()
返回带有 .minecraft 路径的字符串(例如“/home/user/.minecraft”)。Eclipse 控制台中没有显示任何内容。我不知道出了什么问题,因为在 bash 中启动的完全相同的命令运行良好。
@EDIT
C:\Users\Łukasz\AppData\Roaming\.minecraft\bin/minecraft.jar:C:\Users\Łukasz\AppData\Roaming\.minecraft\bin/lwjgl.jar:C:\Users\Łukasz\AppData\Roaming\.minecraft\bin/lwjgl_util.jar:C:\Users\Łukasz\AppData\Roaming\.minecraft\bin/jinput.jar
这是那个字符串。我将 / 更改为 \,但没有帮助:<