From a275eb34b9fd9658179e2f606e57c37e64fe27d6 Mon Sep 17 00:00:00 2001 From: Artur Nowosielski Date: Tue, 28 Jun 2016 16:37:37 +0200 Subject: [PATCH] Fixed handling jdk-* and jre-* Java installation paths --- capsule/src/main/java/Capsule.java | 5 ++++- capsule/src/test/java/CapsuleTest.java | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/capsule/src/main/java/Capsule.java b/capsule/src/main/java/Capsule.java index cc7e70dc..815bfca3 100644 --- a/capsule/src/main/java/Capsule.java +++ b/capsule/src/main/java/Capsule.java @@ -4103,8 +4103,11 @@ static String isJavaDir(String fileName) { m.find(); return shortJavaVersion(m.group(1)); } else if (fileName.startsWith("jdk") || fileName.startsWith("jre") || fileName.endsWith(".jdk") || fileName.endsWith(".jre")) { - if (fileName.startsWith("jdk") || fileName.startsWith("jre")) + if (fileName.startsWith("jdk-") || fileName.startsWith("jre-")) + fileName = fileName.substring(4); + else if (fileName.startsWith("jdk") || fileName.startsWith("jre")) fileName = fileName.substring(3); + if (fileName.endsWith(".jdk") || fileName.endsWith(".jre")) fileName = fileName.substring(0, fileName.length() - 4); return shortJavaVersion(fileName); diff --git a/capsule/src/test/java/CapsuleTest.java b/capsule/src/test/java/CapsuleTest.java index f44189d8..e03b9c72 100644 --- a/capsule/src/test/java/CapsuleTest.java +++ b/capsule/src/test/java/CapsuleTest.java @@ -1300,6 +1300,8 @@ public void isJavaDir() { assertEquals("1.8.0", Capsule.isJavaDir("jdk-8-oracle")); assertEquals("1.8.0", Capsule.isJavaDir("jre-8-oracle")); assertEquals("1.8.0", Capsule.isJavaDir("jdk-8-oracle-x64")); + assertEquals("1.8.0", Capsule.isJavaDir("jdk-1.8.0")); + assertEquals("1.8.0", Capsule.isJavaDir("jre-1.8.0")); } @Test