List of usage examples for org.apache.commons.lang SystemUtils JAVA_HOME
String JAVA_HOME
To view the source code for org.apache.commons.lang SystemUtils JAVA_HOME.
Click Source Link
The java.home
System Property.
From source file:SystemUtilsTrial.java
public static void main(String[] args) { System.out.println("1) FILE_SEPARATOR =" + SystemUtils.FILE_SEPARATOR); System.out.println("2) JAVA_EXT_DIRS =" + SystemUtils.JAVA_EXT_DIRS); System.out.println("3) JAVA_HOME =" + SystemUtils.JAVA_HOME); System.out.println("4) Is 1.3 + =" + SystemUtils.isJavaVersionAtLeast(1.3f)); System.out.println("5) JAVA_EXT_DIRS =" + SystemUtils.JAVA_EXT_DIRS); System.out.println("6) JAVA_VENDOR =" + SystemUtils.JAVA_VENDOR); System.out.println("7) OS_NAME =" + SystemUtils.OS_NAME); }
From source file:com.yahoo.flowetl.commons.runner.Main.java
/** * Gets some useful runtime info as a map of names -> info. *///w w w .j a v a 2s .co m private static Map<String, Object> getRuntimeInfo() { Map<String, Object> sysInfo = new TreeMap<String, Object>(); StringBuilder jvminfo = new StringBuilder(); jvminfo.append("Vendor: "); jvminfo.append(SystemUtils.JAVA_VENDOR); jvminfo.append(", Version: "); jvminfo.append(SystemUtils.JAVA_VERSION + " - " + SystemUtils.JAVA_VM_INFO); jvminfo.append(", OS: "); jvminfo.append(SystemUtils.OS_NAME + " (" + SystemUtils.OS_VERSION + " : " + SystemUtils.OS_ARCH + ")"); sysInfo.put(WordUtils.capitalizeFully("jvm"), jvminfo.toString()); sysInfo.put(WordUtils.capitalizeFully("default charset encoding"), DEF_CHAR_SET.name()); String netAdd = NetUtils.getLocalAddress(); if (StringUtils.isEmpty(netAdd)) { netAdd = "????"; } String localName = NetUtils.getLocalHostName(); if (StringUtils.isEmpty(localName)) { localName = "????"; } sysInfo.put(WordUtils.capitalizeFully("network"), localName + " at ip address " + netAdd); String cPath = SystemUtils.JAVA_CLASS_PATH; String linesep = StringEscapeUtils.escapeJava(SystemUtils.LINE_SEPARATOR); sysInfo.put(WordUtils.capitalizeFully("classpath"), cPath); sysInfo.put(WordUtils.capitalizeFully("jvm home"), SystemUtils.JAVA_HOME); sysInfo.put(WordUtils.capitalizeFully("jvm tmpdir"), SystemUtils.JAVA_IO_TMPDIR); sysInfo.put(WordUtils.capitalizeFully("jvm libpath"), SystemUtils.JAVA_LIBRARY_PATH); sysInfo.put(WordUtils.capitalizeFully("line separator"), linesep); sysInfo.put(WordUtils.capitalizeFully("path separator"), StringEscapeUtils.escapeJava(SystemUtils.PATH_SEPARATOR)); sysInfo.put(WordUtils.capitalizeFully("user timezone"), SystemUtils.USER_TIMEZONE); sysInfo.put(WordUtils.capitalizeFully("user home"), SystemUtils.USER_HOME); sysInfo.put(WordUtils.capitalizeFully("user language"), SystemUtils.USER_LANGUAGE); sysInfo.put(WordUtils.capitalizeFully("user name"), SystemUtils.USER_NAME); return sysInfo; }
From source file:org.eclim.plugin.jdt.PluginResources.java
/** * Performs additional logic to locate jre src zip file in alternate locations * not checked by eclipse.// www . ja v a2 s.c om */ protected void initializeJreSrc() { String jarName = Os.isFamily(Os.FAMILY_MAC) ? "classes.jar" : "rt.jar"; // doing a straight JavaCore.setClasspathVariable() doesn't work, so we need // to modify the library path of the default vm install. try { IVMInstall vm = JavaRuntime.getDefaultVMInstall(); LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vm); LibraryLocation[] newLocations = new LibraryLocation[locations.length]; for (int ii = 0; ii < locations.length; ii++) { IPath libraryPath = locations[ii].getSystemLibraryPath(); // eclipse didn't find src.zip, so search other known locations. if (libraryPath.lastSegment().equals(jarName) && (locations[ii].getSystemLibrarySourcePath().isEmpty() || !locations[ii].getSystemLibrarySourcePath().toFile().exists())) { IPath jreSrc = null; logger.debug("Attempting to locate jre src.zip for JAVA_HOME: {}", SystemUtils.JAVA_HOME); for (int jj = 0; jj < SRC_LOCATIONS.length; jj++) { String location = SRC_LOCATIONS[jj]; // absolute path if (location.startsWith("/") || location.indexOf(':') != -1) { jreSrc = new Path(location); // relative path } else { jreSrc = libraryPath.removeLastSegments(3).append(location); } logger.debug("Trying location: {}", jreSrc); if (jreSrc.toFile().exists()) { break; } } // other possibilities on windows machines: // library path: C:/.../jre<version>/ // src archive: C:/.../jdk<version>/src.zip // or // library path: C:/.../jre<major>/ // src archive: C:/.../jdk1.<major>.<minor>_<patch>/src.zip if (!jreSrc.toFile().exists() && Os.isFamily(Os.FAMILY_WINDOWS)) { String path = libraryPath.toOSString().replaceFirst("\\\\(lib\\\\)rt.jar", ""); // first scenerio String altHome = path.replaceFirst("jre(\\d+\\.\\d+\\.\\d+_\\d+)", "jdk$1"); if (!altHome.equals(path)) { jreSrc = new Path(altHome).append("src.zip"); } // second scenerio if (!jreSrc.toFile().exists()) { String base = FileUtils.getBaseName(path); final String major = base.replaceFirst("^jre(\\d)$", "$1"); if (!major.equals(base)) { File dir = new File(FileUtils.getFullPath(path)); String[] jdks = dir.list(new FilenameFilter() { private final Pattern JDK = Pattern .compile("jdk\\d+\\." + major + "\\.\\d+_\\d+"); public boolean accept(File dir, String name) { return JDK.matcher(name).matches(); } }); for (String jdk : jdks) { jreSrc = new Path(dir.toString()).append(jdk).append("src.zip"); if (jreSrc.toFile().exists()) { break; } } } } } // jre src found. if (jreSrc.toFile().exists()) { logger.info("Setting '{}' to '{}'", JavaRuntime.JRESRC_VARIABLE, jreSrc); newLocations[ii] = new LibraryLocation(locations[ii].getSystemLibraryPath(), jreSrc, locations[ii].getPackageRootPath(), locations[ii].getJavadocLocation()); // jre src not found. } else { logger.debug("Unable to locate jre src.zip for JAVA_HOME: " + SystemUtils.JAVA_HOME); newLocations[ii] = new LibraryLocation(locations[ii].getSystemLibraryPath(), Path.EMPTY, locations[ii].getPackageRootPath(), locations[ii].getJavadocLocation()); } } else { newLocations[ii] = locations[ii]; } } vm.setLibraryLocations(newLocations); } catch (Exception e) { logger.error("", e); } }