Browse Source

find tools.jar even if it is distributed with the JRE, submitted by Nick Crossley, PR 38500

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@392037 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 19 years ago
parent
commit
4071974a6a
2 changed files with 10 additions and 1 deletions
  1. +4
    -0
      contributors.xml
  2. +6
    -1
      src/main/org/apache/tools/ant/launch/Locator.java

+ 4
- 0
contributors.xml View File

@@ -666,6 +666,10 @@
<first>Nick</first> <first>Nick</first>
<last>Chalko</last> <last>Chalko</last>
</name> </name>
<name>
<first>Nick</first>
<last>Crossley</last>
</name>
<name> <name>
<first>Nick</first> <first>Nick</first>
<last>Fortescue</last> <last>Fortescue</last>


+ 6
- 1
src/main/org/apache/tools/ant/launch/Locator.java View File

@@ -339,10 +339,15 @@ public final class Locator {
// couldn't find compiler - try to find tools.jar // couldn't find compiler - try to find tools.jar
// based on java.home setting // based on java.home setting
String javaHome = System.getProperty("java.home"); String javaHome = System.getProperty("java.home");
File toolsJar = new File(javaHome + "/lib/tools.jar");
if (toolsJar.exists()) {
// Found in java.home as given
return toolsJar;
}
if (javaHome.toLowerCase(Locale.US).endsWith(File.separator + "jre")) { if (javaHome.toLowerCase(Locale.US).endsWith(File.separator + "jre")) {
javaHome = javaHome.substring(0, javaHome.length() - 4); javaHome = javaHome.substring(0, javaHome.length() - 4);
toolsJar = new File(javaHome + "/lib/tools.jar");
} }
File toolsJar = new File(javaHome + "/lib/tools.jar");
if (!toolsJar.exists()) { if (!toolsJar.exists()) {
System.out.println("Unable to locate tools.jar. " System.out.println("Unable to locate tools.jar. "
+ "Expected to find it in " + toolsJar.getPath()); + "Expected to find it in " + toolsJar.getPath());


Loading…
Cancel
Save