List of usage examples for org.apache.commons.lang SystemUtils IS_OS_MAC_OSX
boolean IS_OS_MAC_OSX
To view the source code for org.apache.commons.lang SystemUtils IS_OS_MAC_OSX.
Click Source Link
Is true
if this is Mac.
The field will return false
if OS_NAME
is null
.
From source file:org.apache.maven.plugin.javadoc.JavadocUtil.java
/** * @param log a logger could be null//from w ww .j a va 2s . c om * @return the <code>JAVA_HOME</code> from System.getProperty( "java.home" ) * By default, <code>System.getProperty( "java.home" ) = JRE_HOME</code> and <code>JRE_HOME</code> * should be in the <code>JDK_HOME</code> * @since 2.6 */ private static File getJavaHome(Log log) { File javaHome; if (SystemUtils.IS_OS_MAC_OSX) { javaHome = SystemUtils.getJavaHome(); } else { javaHome = new File(SystemUtils.getJavaHome(), ".."); } if (javaHome == null || !javaHome.exists()) { try { javaHome = new File(CommandLineUtils.getSystemEnvVars().getProperty("JAVA_HOME")); } catch (IOException e) { if (log != null && log.isDebugEnabled()) { log.debug("IOException: " + e.getMessage()); } } } if (javaHome == null || !javaHome.exists()) { if (log != null && log.isErrorEnabled()) { log.error( "Cannot find Java application directory. Either specify \'java.home\' system property, or " + "JAVA_HOME environment variable."); } } return javaHome; }
From source file:org.apache.maven.plugin.jdeps.AbstractJDepsMojo.java
private String getJDepsExecutable() throws IOException { Toolchain tc = getToolchain();/*w ww .j av a2 s . c o m*/ String jdepsExecutable = null; if (tc != null) { jdepsExecutable = tc.findTool("jdeps"); } String jdepsCommand = "jdeps" + (SystemUtils.IS_OS_WINDOWS ? ".exe" : ""); File jdepsExe; if (StringUtils.isNotEmpty(jdepsExecutable)) { jdepsExe = new File(jdepsExecutable); if (jdepsExe.isDirectory()) { jdepsExe = new File(jdepsExe, jdepsCommand); } if (SystemUtils.IS_OS_WINDOWS && jdepsExe.getName().indexOf('.') < 0) { jdepsExe = new File(jdepsExe.getPath() + ".exe"); } if (!jdepsExe.isFile()) { throw new IOException("The jdeps executable '" + jdepsExe + "' doesn't exist or is not a file."); } return jdepsExe.getAbsolutePath(); } // ---------------------------------------------------------------------- // Try to find jdepsExe from System.getProperty( "java.home" ) // By default, System.getProperty( "java.home" ) = JRE_HOME and JRE_HOME // should be in the JDK_HOME // ---------------------------------------------------------------------- // For IBM's JDK 1.2 if (SystemUtils.IS_OS_AIX) { jdepsExe = new File(SystemUtils.getJavaHome() + File.separator + ".." + File.separator + "sh", jdepsCommand); } // For Apple's JDK 1.6.x (and older?) on Mac OSX // CHECKSTYLE_OFF: MagicNumber else if (SystemUtils.IS_OS_MAC_OSX && SystemUtils.JAVA_VERSION_FLOAT < 1.7f) // CHECKSTYLE_ON: MagicNumber { jdepsExe = new File(SystemUtils.getJavaHome() + File.separator + "bin", jdepsCommand); } else { jdepsExe = new File(SystemUtils.getJavaHome() + File.separator + ".." + File.separator + "bin", jdepsCommand); } // ---------------------------------------------------------------------- // Try to find jdepsExe from JAVA_HOME environment variable // ---------------------------------------------------------------------- if (!jdepsExe.exists() || !jdepsExe.isFile()) { Properties env = CommandLineUtils.getSystemEnvVars(); String javaHome = env.getProperty("JAVA_HOME"); if (StringUtils.isEmpty(javaHome)) { throw new IOException("The environment variable JAVA_HOME is not correctly set."); } if ((!new File(javaHome).getCanonicalFile().exists()) || (new File(javaHome).getCanonicalFile().isFile())) { throw new IOException("The environment variable JAVA_HOME=" + javaHome + " doesn't exist or is not a valid directory."); } jdepsExe = new File(javaHome + File.separator + "bin", jdepsCommand); } if (!jdepsExe.getCanonicalFile().exists() || !jdepsExe.getCanonicalFile().isFile()) { throw new IOException("The jdeps executable '" + jdepsExe + "' doesn't exist or is not a file. Verify the JAVA_HOME environment variable."); } return jdepsExe.getAbsolutePath(); }
From source file:org.apache.maven.plugins.linkcheck.SiteInvoker.java
/** * @return the <code>JAVA_HOME</code> from System.getProperty( "java.home" ) * By default, <code>System.getProperty( "java.home" ) = JRE_HOME</code> and <code>JRE_HOME</code> * should be in the <code>JDK_HOME</code> or null if not setted. * @see #invoke(Invoker, InvocationRequest, File, List, Properties, String) *///from ww w .j av a2 s . c o m private File getJavaHome() { File javaHome; if (SystemUtils.IS_OS_MAC_OSX) { javaHome = SystemUtils.getJavaHome(); } else { javaHome = new File(SystemUtils.getJavaHome(), ".."); } if (javaHome == null || !javaHome.exists()) { try { javaHome = new File(CommandLineUtils.getSystemEnvVars().getProperty("JAVA_HOME")); } catch (IOException e) { getLog().error("IOException: " + e.getMessage()); getLog().debug(e); } } if (javaHome == null || !javaHome.exists()) { getLog().error("Cannot find Java application directory. Either specify \'java.home\' " + "system property, or JAVA_HOME environment variable."); } return javaHome; }
From source file:org.caleydo.core.view.opengl.canvas.AGLCanvas.java
/** * *//* w w w.j av a 2s . c om*/ protected void triggerResize() { if (!SystemUtils.IS_OS_MAC_OSX) // mac special return; Composite c = asComposite(); c.layout(true); org.eclipse.swt.graphics.Point size = c.getSize(); // change the size of composite to force some surface updates, see # c.setSize(size.x - 1, size.y); }
From source file:org.caleydo.core.view.opengl.layout2.internal.SandBoxLibraryLoader.java
/** * extract the given library of the classpath and put it to a temporary file *//* ww w. j ava 2 s .c o m*/ public static File toTemporaryFile(String libName) throws IOException { // convert to native library name libName = System.mapLibraryName(libName); if (SystemUtils.IS_OS_MAC_OSX) libName = StringUtils.replace(libName, ".dylib", ".jnilib"); // create String extension = Files.getFileExtension(libName); File file = File.createTempFile(StringUtils.removeEnd(libName, extension), "." + extension); file.deleteOnExit(); URL res = SandBoxLibraryLoader.class.getResource("/" + libName); if (res == null) throw new FileNotFoundException("can't extract: " + libName); try (InputStream in = res.openStream(); OutputStream to = new BufferedOutputStream(new FileOutputStream(file))) { ByteStreams.copy(in, to); } catch (IOException e) { System.err.println("can't extract: " + libName); e.printStackTrace(); throw new FileNotFoundException("can't extract: " + libName); } return file; }
From source file:org.cleartk.util.PlatformDetection.java
public PlatformDetection() { // resolve OS if (SystemUtils.IS_OS_WINDOWS) { this.os = OS_WINDOWS; } else if (SystemUtils.IS_OS_MAC_OSX) { this.os = OS_OSX; } else if (SystemUtils.IS_OS_SOLARIS) { this.os = OS_SOLARIS; } else if (SystemUtils.IS_OS_LINUX) { this.os = OS_LINUX; } else {/* www . j av a 2 s .c o m*/ throw new IllegalArgumentException("Unknown operating system " + SystemUtils.OS_NAME); } // resolve architecture Map<String, String> archMap = new HashMap<String, String>(); archMap.put("x86", ARCH_X86_32); archMap.put("i386", ARCH_X86_32); archMap.put("i486", ARCH_X86_32); archMap.put("i586", ARCH_X86_32); archMap.put("i686", ARCH_X86_32); archMap.put("x86_64", ARCH_X86_64); archMap.put("amd64", ARCH_X86_64); archMap.put("powerpc", ARCH_PPC); this.arch = archMap.get(SystemUtils.OS_ARCH); if (this.arch == null) { throw new IllegalArgumentException("Unknown architecture " + SystemUtils.OS_ARCH); } }
From source file:org.codehaus.mojo.jspc.CompilationMojoSupport.java
/** * Figure out where the tools.jar file lives. *///from www . j a va 2 s . c o m private URL findToolsJar() throws MojoExecutionException { final File javaHome = FileUtils.resolveFile(new File(File.pathSeparator), System.getProperty("java.home")); final List<File> toolsPaths = new ArrayList<File>(); File file = null; if (SystemUtils.IS_OS_MAC_OSX) { file = FileUtils.resolveFile(javaHome, "../Classes/classes.jar"); toolsPaths.add(file); } if (file == null || !file.exists()) { file = FileUtils.resolveFile(javaHome, "../lib/tools.jar"); toolsPaths.add(file); } if (!file.exists()) { throw new MojoExecutionException( "Could not find tools.jar at " + toolsPaths + " under java.home: " + javaHome); } getLog().debug("Using tools.jar: " + file); final URI fileUri = file.toURI(); try { return fileUri.toURL(); } catch (MalformedURLException e) { throw new MojoExecutionException("Could not generate URL from URI: " + fileUri, e); } }
From source file:org.codehaus.mojo.keytool.GenkeyMojo.java
private static File getJDKCommandExe(String command) { String fullCommand = command + (SystemUtils.IS_OS_WINDOWS ? ".exe" : ""); File exe;/*ww w.j av a 2s .com*/ // For IBM's JDK 1.2 if (SystemUtils.IS_OS_AIX) { exe = new File(SystemUtils.getJavaHome() + "/../sh", fullCommand); } else if (SystemUtils.IS_OS_MAC_OSX) // what about IS_OS_MAC_OS ?? { exe = new File(SystemUtils.getJavaHome() + "/bin", fullCommand); } else { exe = new File(SystemUtils.getJavaHome() + "/../bin", fullCommand); } return exe; }
From source file:org.codehaus.mojo.keytool.KeyToolMojoSupport.java
/** * Constructs the operating system specific File path of the JDK command given the specified command name. * @param command the executable name // w ww . ja v a 2 s . com * @return a File representing the path to the command. */ public static File getJDKCommandExe(String command) { String fullCommand = command + (SystemUtils.IS_OS_WINDOWS ? ".exe" : ""); File exe; // For IBM's JDK 1.2 if (SystemUtils.IS_OS_AIX) { exe = new File(SystemUtils.getJavaHome() + "/../sh", fullCommand); } else if (SystemUtils.IS_OS_MAC_OSX) // what about IS_OS_MAC_OS ?? { exe = new File(SystemUtils.getJavaHome() + "/bin", fullCommand); } else { exe = new File(SystemUtils.getJavaHome() + "/../bin", fullCommand); } return exe; }
From source file:org.codehaus.mojo.keytool.KeyToolMojoSupport.java
/** * Constructs the operating system specific File path of the JRE cacerts file. * @param command the executable name /*from w ww . j a v a 2 s. co m*/ * @return a File representing the path to the command. */ public static File getJRECACerts() { File cacertsFile = null; String cacertsFilepath = "lib/security/cacerts"; // For IBM's JDK 1.2 if (SystemUtils.IS_OS_AIX) { cacertsFile = new File(SystemUtils.getJavaHome() + "/", cacertsFilepath); } else if (SystemUtils.IS_OS_MAC_OSX) // what about IS_OS_MAC_OS ?? { cacertsFile = new File(SystemUtils.getJavaHome() + "/", cacertsFilepath); } else { cacertsFile = new File(SystemUtils.getJavaHome() + "/", cacertsFilepath); } return cacertsFile; }