提交 14b1be3c authored 作者: christian.peter.io's avatar christian.peter.io

Try to use current java executable path, not the one in %PATH% (there could be a…

Try to use current java executable path, not the one in %PATH% (there could be a reference to an old one)
上级 db4ebf32
......@@ -61,6 +61,7 @@ public class Migrate {
* @throws Exception if conversion fails
*/
public void execute(File file, boolean recursive, String user, String password, boolean runQuiet) throws Exception {
String pathToJavaExe = getJavaExecutablePath();
this.quiet = runQuiet;
if (file.isDirectory() && recursive) {
for (File f : file.listFiles()) {
......@@ -78,7 +79,7 @@ public class Migrate {
String url = "jdbc:h2:" + file.getAbsolutePath();
url = url.substring(0, url.length() - ".data.db".length());
exec(new String[] {
"java",
pathToJavaExe,
"-Xmx128m",
"-cp", OLD_H2_FILE.getAbsolutePath(),
"org.h2.tools.Script",
......@@ -92,6 +93,20 @@ public class Migrate {
new File(TEMP_SCRIPT).delete();
}
private String getJavaExecutablePath() {
String pathToJava;
if (File.separator.equals("\\")) {
pathToJava = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java.exe";
} else {
pathToJava = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
}
if (!new File(pathToJava).exists()) {
// Fallback to old behaviour
pathToJava = "java";
}
return pathToJava;
}
private void download(String target, String fileURL, String sha1Checksum) {
File targetFile = new File(target);
if (targetFile.exists()) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论