我将尝试在这个问题中尽可能描述,因为它很难解释..
开始。我有两个 jar 文件。一个(我自己的)和一个(The Bukkit jar)。bukkit jar,我喜欢在“./Server/bukkit.jar”中访问我正在运行的 bukkit jar 实例中的方法“org.bukkit.Bukkit.getServer()”,该实例由我自己的 processbuilder 启动罐..
所以在这里..
我自己的罐子代码:
public class Fukkit {
public static void main(String[] args){
ProcessBuilder pb = new ProcessBuilder("java", "-cp", "bukkit.jar", "org.bukkit.craftbukkit.Main");
pb.directory(new File(new File(".").getPath() + File.separator + "Server"));
try {
pb.start();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//I now want to access that instance of bukkit.jar, and use the method
org.bukkit.Bukkit.getServer();
//From inside the jar..
//I cannot add it as a library, because the jar may be swapped out
//for another more updated version of bukkit.jar..
//But that method will always be present. Can someone help me out..?
}
}