On 17 November 2013 21:52, <[email protected]> wrote: > Author: pmouawad > Date: Sun Nov 17 21:52:37 2013 > New Revision: 1542840 > > URL: http://svn.apache.org/r1542840 > Log: > getJavaHome does not work on Mac OSX. > Use Commons Lang method
Not sure why I did not notice that java.home would be simpler. Note that the Lang method does not return the same value as the JorphanUtils one. On Windows, I get C:\jdk1.6.0_45 - JorphanUtils C:\jdk1.6.0_45\jre - SystemUtils.getJavaHome(); As it happens, bin/keytool[.exe] is present under both those directories, so that's not an issue. Not sure it makes any sense to keep the JorphanUtils method now. I think I'll remove it. > Modified: > jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java > > Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java > URL: > http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java?rev=1542840&r1=1542839&r2=1542840&view=diff > ============================================================================== > --- jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java > (original) > +++ jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java Sun > Nov 17 21:52:37 2013 > @@ -25,13 +25,13 @@ import java.io.InputStream; > import java.io.OutputStream; > import java.net.ServerSocket; > import java.net.Socket; > -import java.net.URL; > import java.util.ArrayList; > import java.util.List; > import java.util.Map; > import java.util.StringTokenizer; > > import org.apache.commons.lang3.StringUtils; > +import org.apache.commons.lang3.SystemUtils; > > /** > * This class contains frequently-used static utility methods. > @@ -577,17 +577,6 @@ public final class JOrphanUtils { > * @return the home location of Java, or {@code null} if the method fails > */ > public static File getJavaHome() { > - // For example: > jar:file:/C:/jdk1.6.0_45/jre/lib/rt.jar!/java/lang/Object.class > - URL resource = Object.class.getResource("Object.class"); // > might not work with some Java implementations > - if (resource == null) { > - return null; > - } > - String path = resource.getPath(); > - // For example: > file:/C:/jdk1.6.0_45/jre/lib/rt.jar!/java/lang/Object.class > - path = path.replace("file:","").replaceFirst("!.+", ""); > - // e.g. /C:/jdk1.6.0_45/jre/lib/rt.jar > - File rt = new File(path); > - return rt.getParentFile().getParentFile().getParentFile(); > + return SystemUtils.getJavaHome(); > } > - > } > \ No newline at end of file > >
