按照ashingel的建議,我決定在初始化時將門資源解壓到臨時文件夾,如果它是從JAR文件運行的。
對於如何解壓文件夾中看到我的答案在這裏的細節:https://stackoverflow.com/a/16659655/281469
這裏是什麼,我(注:Apache的百科全書IO依賴):在做初始化一個例子使用
//My GATE resources are in the "/gate" folder of the JAR
URI url = getClass().getResource("/gate").toURI();
File gateHome;
if (url.isOpaque()) {
logger.info("Unpacking GATE resources from JAR");
String tempDirectoryPath = FileUtils.getTempDirectoryPath();
String gateResource = "gate";
//Delete any existing temporary directory
FileUtils.deleteDirectory(new File(FilenameUtils.concat(tempDirectoryPath, gateResource)));
String gateHomePath = extractDirectoryFromClasspathJAR(getClass(), gateResource, tempDirectoryPath);
gateHome = new File(gateHomePath);
} else {
gateHome = new File(url);
}
Gate.setGateHome(gateHome);