Java Code Examples for org.apache.commons.lang3.SystemUtils#IS_OS_MAC_OSX

The following examples show how to use org.apache.commons.lang3.SystemUtils#IS_OS_MAC_OSX . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SysUtils.java    From mvn-golang with Apache License 2.0 6 votes vote down vote up
@Nullable
public static String findGoSdkOsType() {
  final String result;
  if (SystemUtils.IS_OS_WINDOWS) {
    result = "windows";
  } else if (SystemUtils.IS_OS_FREE_BSD) {
    result = "freebsd";
  } else if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) {
    result = "darwin";
  } else if (SystemUtils.IS_OS_LINUX) {
    result = "linux";
  } else {
    result = null;
  }
  return result;
}
 
Example 2
Source File: Main.java    From swift-t with Apache License 2.0 6 votes vote down vote up
public static boolean useGCCProcessor() {
  try {
    if ((SystemUtils.IS_OS_MAC_OSX &&
        !Settings.getBoolean(Settings.PREPROCESSOR_FORCE_CPP))) {
      return true;
    } else if (Settings.getBoolean(Settings.PREPROCESSOR_FORCE_GCC)) {
      return true;
    } else {
      return false;
    }
  } catch (InvalidOptionException e) {
    System.out.println("Internal error with settings: " + e.getMessage());
    System.exit(ExitCode.ERROR_INTERNAL.code());
    return false;
  }
}
 
Example 3
Source File: ConfigurationSettings.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * @return A default Settings Files Path value.
 */
public static String getDefaultSettingsFilesPath()
{
	String fType;
	if (SystemUtils.IS_OS_MAC_OSX)
	{
		fType = SettingsFilesPath.mac_user.name();
	}
	else if (SystemUtils.IS_OS_UNIX)
	{
		fType = SettingsFilesPath.FD_USER.name();
	}
	else
	{
		fType = SettingsFilesPath.user.name();
	}
	return fType;
}
 
Example 4
Source File: FileAppenderPermissionsTest.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
public static String findAGroup(final String user) throws IOException {
    if (SystemUtils.IS_OS_MAC_OSX) {
        return "staff";
    }
    String group = user;
    try (FileInputStream fis = new FileInputStream("/etc/group")) {
        final List<String> groups = org.apache.commons.io.IOUtils.readLines(fis, Charset.defaultCharset());
        for (int i = 0; i < groups.size(); i++) {
            final String aGroup = groups.get(i);
            if (!aGroup.startsWith(user) && aGroup.contains(user)) {
                group = aGroup.split(":")[0];
                break;
            }
        }
    }
    return group;
}
 
Example 5
Source File: SettingsPathTool.java    From VocabHunter with Apache License 2.0 5 votes vote down vote up
public static Path obtainSettingsFilePath(final String filename) {
    if (SystemUtils.IS_OS_WINDOWS && StringUtils.isNotBlank(getWindowsAppHome())) {
        return Paths.get(getWindowsAppHome(), VOCAB_HUNTER, filename);
    } else if (SystemUtils.IS_OS_MAC_OSX) {
        return Paths.get(getUserHome(), "Library", VOCAB_HUNTER, filename);
    } else {
        return Paths.get(getUserHome(), ".VocabHunter", filename);
    }
}
 
Example 6
Source File: EarthApp.java    From collect-earth with MIT License 5 votes vote down vote up
/**
 * Start the application, opening Google Earth and starting the Jetty server.
 * 
 * @param args
 *            No arguments are used by this method.
 */
public static void main(String[] args) {

	try {

		// System property used in the web.xml configuration
		System.setProperty("collectEarth.userFolder", FolderFinder.getCollectEarthDataFolder()); //$NON-NLS-1$

		initializeSentry();

		// Change of font so that Lao and Thao glyphs are supported
		CollectEarthUtils.setFontDependingOnLanguaue( getLocalProperties().getUiLanguage() );

		logger = LoggerFactory.getLogger(EarthApp.class);

		String doubleClickedProjectFile = null;

		if (args != null && args.length == 1) {
			doubleClickedProjectFile = args[0];
		}else if( getProjectsService().getProjectList().size() == 0 ){
			doubleClickedProjectFile = "resources/demo_survey.cep";
		}

		if ( SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX){
			handleMacStartup( doubleClickedProjectFile );
		}else{
			startCollectEarth( doubleClickedProjectFile );
		}

	} catch (final Exception e) {
		// The logger factory has not been initialized, this will not work, just output to console
		if (logger != null) {
			logger.error("The server could not start", e); //$NON-NLS-1$
		}
		e.printStackTrace();
		System.exit(1);
	} finally {
		closeSplash();
	}
}
 
Example 7
Source File: AnalysisSaikuService.java    From collect-earth with MIT License 5 votes vote down vote up
private void setMacJreHome(ProcessBuilder p) {
	if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_LINUX) {

		File javaFolder = new File("./java");

		if (!javaFolder.exists()) {
			String userName = System.getProperty("user.name");
			String testWithPath = "/Users/" + userName + "/OpenForis/CollectEarth/java";
			File testJavaPath = new File(testWithPath);
			if (testJavaPath.exists()) {
				javaFolder = testJavaPath;
			}
		}

		Map<String, String> environment = p.environment();
		environment.put("COLLECT_EARTH_JRE_HOME", javaFolder.getAbsolutePath());

		/*
		 * // In MAC the environment variable COLLECT_EARTH_JRE_HOME is not accesible
		 * from outside the bash, set it again! if( SystemUtils.IS_OS_MAC ||
		 * SystemUtils.IS_OS_MAC_OSX){ try { File javaFolder = new File("./java");
		 * 
		 * if( !javaFolder.exists() ){ String userName =
		 * System.getProperty("user.name"); String testWithPath = "/Users/"+userName +
		 * "/OpenForis/CollectEarth/java"; File testJavaPath = new File(testWithPath);
		 * if( testJavaPath.exists()){ javaFolder = testJavaPath; } }
		 * 
		 * Process setEnv = runProcessBuilder(new String[] { "/bin/bash", "setenv",
		 * "COLLECT_EARTH_JRE_HOME=\""+ javaFolder.getAbsolutePath() +"\"" });
		 * setEnv.waitFor(); } catch (final IOException e) {
		 * logger.error("Error setting the COLLECT_EARTH_JRE_HOME environment variable",
		 * e); //$NON-NLS-1$ } catch (InterruptedException e) {
		 * logger.error("Error when running COLLECT_EARTH_JRE_HOME environment variable"
		 * , e); //$NON-NLS-1$ } }
		 */
	}
}
 
Example 8
Source File: Hardware.java    From stevia with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static final String getSerialNumber() {
	// lets gather what we can
	String osString = System.getProperty("os.name") + "-"
			+ System.getProperty("os.version") + "-"
			+ System.getProperty("os.arch");
	try {
		if (SystemUtils.IS_OS_WINDOWS) {
			return H4W.getSerialNumber() + ":WIN";
		}
		if (SystemUtils.IS_OS_LINUX) {
			return H4N.getSerialNumber() + ":LIN";
		}
		if (SystemUtils.IS_OS_MAC_OSX) {
			return H4M.getSerialNumber() + ":MAC";
		}
		if (SystemUtils.IS_OS_SOLARIS) {
			return H4S.getSerialNumber()
					+ ":S"
					+ (SystemUtils.OS_VERSION == null ? "OL"
							: SystemUtils.OS_VERSION);
		}
	} catch (Exception e) {
		// if we're here, we dont know what this is.
		return osString + ":EXC";
	}
	// if we're here then lets note it's unknown
	return osString + ":UNK";
}
 
Example 9
Source File: CommonUtils.java    From sahagin-java with Apache License 2.0 5 votes vote down vote up
private static boolean filePathEquals(String path1, String path2) {
    // Mac is case-insensitive, but IOCase.SYSTEM.isCaseSenstive returns true,
    // so don't use this value for Mac.
    // (TODO but Mac can become case-sensitive if an user changes system setting..)
    if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) {
        return StringUtils.equalsIgnoreCase(path1, path2);
    }
    if (IOCase.SYSTEM.isCaseSensitive()) {
        return StringUtils.equals(path1, path2);
    } else {
        return StringUtils.equalsIgnoreCase(path1, path2);
    }
}
 
Example 10
Source File: EmbeddedUtil.java    From otj-pg-embedded with Apache License 2.0 5 votes vote down vote up
/**
 * Get current operating system string. The string is used in the appropriate
 * postgres binary name.
 *
 * @return Current operating system string.
 */
static String getOS() {
    if (SystemUtils.IS_OS_WINDOWS) {
        return "Windows";
    }
    if (SystemUtils.IS_OS_MAC_OSX) {
        return "Darwin";
    }
    if (SystemUtils.IS_OS_LINUX) {
        return "Linux";
    }
    throw new UnsupportedOperationException("Unknown OS " + SystemUtils.OS_NAME);
}
 
Example 11
Source File: OptionsPathDialogController.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@FXML
void initialize()
{
	model.directoryProperty().bindBidirectional(dirSelection.textProperty());
	select.selectedProperty().addListener((
			(observable, oldValue, newValue) -> {
				dirSelection.setDisable(!select.isSelected());
				dirSelection.setEditable(select.isSelected());
				selectButton.setDisable(!select.isSelected());
			}));

	if (!SystemUtils.IS_OS_MAC_OSX)
	{
		macUserDir.setVisible(false);
	}
	if (!SystemUtils.IS_OS_UNIX)
	{
		freedesktop.setVisible(false);
	}

	directoryGroup.selectedToggleProperty().addListener((observable, oldValue, newValue)  -> {
		Logging.debugPrint("toggle changed " + observable);
		if (newValue.getUserData() != null)
		{
			String userData = (String) newValue.getUserData();
			Logging.debugPrint("user data is " + userData);
			String newDir = ConfigurationSettings.getSettingsDirFromFilePath(userData);
			model.directoryProperty().setValue(newDir);
		}
	});
}
 
Example 12
Source File: DriverConfiguration.java    From JYTB with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("Duplicates")
public static void validateDriver(Driver driverType)
{
    switch ( driverType.name() )
    {
        case Constants.FIREFOX:
            if (SystemUtils.IS_OS_MAC_OSX)
                driverExists(FIREFOX_MAC);
            else if (SystemUtils.IS_OS_WINDOWS)
                driverExists(FIREFOX_WIN_32, FIREFOX_WIN_64);
            else
                driverExists(FIREFOX_LINUX); 
            break;
        case Constants.CHROME:
            if (SystemUtils.IS_OS_MAC_OSX)
                driverExists(CHROME_MAC);
            else if (SystemUtils.IS_OS_WINDOWS)
                driverExists(CHROME_WIN_32, CHROME_WIN_64);
            else
                driverExists(CHROME_LINUX); 
            break;
        case Constants.SAFARI:
        case Constants.OPERA:
        case Constants.EDGE:
            break;
    }
}
 
Example 13
Source File: OptionsPathDialogController.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@FXML
void initialize()
{
	model.directoryProperty().bindBidirectional(dirSelection.textProperty());
	select.selectedProperty().addListener((
			(observable, oldValue, newValue) -> {
				dirSelection.setDisable(!select.isSelected());
				dirSelection.setEditable(select.isSelected());
				selectButton.setDisable(!select.isSelected());
			}));

	if (!SystemUtils.IS_OS_MAC_OSX)
	{
		macUserDir.setVisible(false);
	}
	if (!SystemUtils.IS_OS_UNIX)
	{
		freedesktop.setVisible(false);
	}

	directoryGroup.selectedToggleProperty().addListener((observable, oldValue, newValue)  -> {
		Logging.debugPrint("toggle changed " + observable);
		if (newValue.getUserData() != null)
		{
			String userData = (String) newValue.getUserData();
			Logging.debugPrint("user data is " + userData);
			String newDir = ConfigurationSettings.getSettingsDirFromFilePath(userData);
			model.directoryProperty().setValue(newDir);
		}
	});
}
 
Example 14
Source File: NativeBundle.java    From spoofax with Apache License 2.0 5 votes vote down vote up
/**
 * @return URI to the native directory. Can point to a directory on the local file system, or to a directory in a
 *         JAR file.
 */
public static URI getNativeDirectory() {
    if(SystemUtils.IS_OS_WINDOWS) {
        return getResource("native/cygwin/");
    } else if(SystemUtils.IS_OS_MAC_OSX) {
        return getResource("native/macosx/");
    } else if(SystemUtils.IS_OS_LINUX) {
        return getResource("native/linux/");
    } else {
        throw new UnsupportedOperationException("Unsupported platform " + SystemUtils.OS_NAME);
    }
}
 
Example 15
Source File: ChromeEmulators.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
/**
 * As per Chromium
 * https://www.chromium.org/user-experience/user-data-directory
 * @return Preferences location
 */
public static String getPrefLocation() {
    if (SystemUtils.IS_OS_WINDOWS) {
        return SystemUtils.getUserHome().getAbsolutePath() + "/AppData/Local/Google/Chrome/User Data/Default";
    }
    if (SystemUtils.IS_OS_MAC_OSX) {
        return SystemUtils.getUserHome().getAbsolutePath()+"/Library/Application Support/Google/Chrome/Default";
    }
    if (SystemUtils.IS_OS_LINUX) {
        return SystemUtils.getUserHome().getAbsolutePath()+"/.config/google-chrome/Default";
    }
    return "OSNotConfigured";
}
 
Example 16
Source File: EditCommands.java    From hdfs-shell with Apache License 2.0 5 votes vote down vote up
public String[] getEditor() {
    if (StringUtils.isEmpty(this.editor)) {
        if (SystemUtils.IS_OS_WINDOWS) {
            return new String[]{"notepad.exe"};
        }
        if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) {
            return new String[]{"vim"};
        }
        return new String[]{"vim"};
    } else {
        return BashUtils.parseArguments(this.editor);
    }
}
 
Example 17
Source File: DriverConfiguration.java    From JYTB with GNU General Public License v3.0 5 votes vote down vote up
public static File getDriver()
    {
       //  return new File(FIREFOX_LINUX);
//
        if (SystemUtils.IS_OS_MAC_OSX)
            return new File(FIREFOX_MAC);
        else if (SystemUtils.IS_OS_WINDOWS)
            return new File(FIREFOX_WIN_32, FIREFOX_WIN_64);
        else
            return new File(FIREFOX_LINUX);
    }
 
Example 18
Source File: LocationPanel.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void setOptionsBasedOnControls()
{
	PCGenSettings.getInstance().setProperty(PCGenSettings.PCG_SAVE_PATH, pcgenCharacterDir.getText());
	PCGenSettings.getInstance().setProperty(PCGenSettings.CHAR_PORTRAITS_PATH, pcgenPortraitsDir.getText());
	PCGenSettings.getInstance().setProperty(PCGenSettings.CUSTOM_DATA_DIR, pcgenCustomDir.getText());
	PCGenSettings.getInstance().setProperty(PCGenSettings.VENDOR_DATA_DIR, pcgenVendorDataDir.getText());
	PCGenSettings.getInstance().setProperty(PCGenSettings.HOMEBREW_DATA_DIR, pcgenHomebrewDataDir.getText());
	ConfigurationSettings.setSystemProperty(ConfigurationSettings.PCC_FILES_DIR, pcgenDataDir.getText());
	ConfigurationSettings.setSystemProperty(ConfigurationSettings.DOCS_DIR, pcgenDocsDir.getText());
	ConfigurationSettings.setSystemProperty(ConfigurationSettings.SYSTEMS_DIR, pcgenSystemDir.getText());
	if (pcgenFilesDirRadio.isSelected())
	{
		ConfigurationSettings.setSystemProperty(ConfigurationSettings.SETTINGS_FILES_PATH,
			SettingsFilesPath.pcgen.name());
	}
	else if (usersFilesDirRadio.isSelected())
	{
		if (SystemUtils.IS_OS_MAC_OSX)
		{
			ConfigurationSettings.setSystemProperty(ConfigurationSettings.SETTINGS_FILES_PATH,
				SettingsFilesPath.mac_user.name());
		}
		else
		{
			ConfigurationSettings.setSystemProperty(ConfigurationSettings.SETTINGS_FILES_PATH,
				SettingsFilesPath.user.name());
		}
	}
	else
	{
		ConfigurationSettings.setSystemProperty(ConfigurationSettings.SETTINGS_FILES_PATH, pcgenFilesDir.getText());
	}
	ConfigurationSettings.setSystemProperty(ConfigurationSettings.SETTINGS_FILES_PATH, pcgenFilesDir.getText());
	ConfigurationSettings.setSystemProperty(ConfigurationSettings.OUTPUT_SHEETS_DIR, pcgenOutputSheetDir.getText());
	PCGenSettings.OPTIONS_CONTEXT.setBoolean(PCGenSettings.OPTION_CREATE_PCG_BACKUP,
		pcgenCreateBackupCharacter.isSelected());
	PCGenSettings.getInstance().setProperty(PCGenSettings.BACKUP_PCG_PATH, pcgenBackupCharacterDir.getText());

	ConfigurationSettings.setSystemProperty(ConfigurationSettings.PREVIEW_DIR, pcgenPreviewDir.getText());
}
 
Example 19
Source File: EnvironmentManagerImpl.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isExitOptionShown() {
    return !SystemUtils.IS_OS_MAC_OSX;
}
 
Example 20
Source File: LocationPanel.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void setOptionsBasedOnControls()
{
	PCGenSettings.getInstance().setProperty(PCGenSettings.PCG_SAVE_PATH, pcgenCharacterDir.getText());
	PCGenSettings.getInstance().setProperty(PCGenSettings.CHAR_PORTRAITS_PATH, pcgenPortraitsDir.getText());
	PCGenSettings.getInstance().setProperty(PCGenSettings.CUSTOM_DATA_DIR, pcgenCustomDir.getText());
	PCGenSettings.getInstance().setProperty(PCGenSettings.VENDOR_DATA_DIR, pcgenVendorDataDir.getText());
	PCGenSettings.getInstance().setProperty(PCGenSettings.HOMEBREW_DATA_DIR, pcgenHomebrewDataDir.getText());
	ConfigurationSettings.setSystemProperty(ConfigurationSettings.PCC_FILES_DIR, pcgenDataDir.getText());
	ConfigurationSettings.setSystemProperty(ConfigurationSettings.DOCS_DIR, pcgenDocsDir.getText());
	ConfigurationSettings.setSystemProperty(ConfigurationSettings.SYSTEMS_DIR, pcgenSystemDir.getText());
	if (pcgenFilesDirRadio.isSelected())
	{
		ConfigurationSettings.setSystemProperty(ConfigurationSettings.SETTINGS_FILES_PATH,
			SettingsFilesPath.pcgen.name());
	}
	else if (usersFilesDirRadio.isSelected())
	{
		if (SystemUtils.IS_OS_MAC_OSX)
		{
			ConfigurationSettings.setSystemProperty(ConfigurationSettings.SETTINGS_FILES_PATH,
				SettingsFilesPath.mac_user.name());
		}
		else
		{
			ConfigurationSettings.setSystemProperty(ConfigurationSettings.SETTINGS_FILES_PATH,
				SettingsFilesPath.user.name());
		}
	}
	else
	{
		ConfigurationSettings.setSystemProperty(ConfigurationSettings.SETTINGS_FILES_PATH, pcgenFilesDir.getText());
	}
	ConfigurationSettings.setSystemProperty(ConfigurationSettings.SETTINGS_FILES_PATH, pcgenFilesDir.getText());
	ConfigurationSettings.setSystemProperty(ConfigurationSettings.OUTPUT_SHEETS_DIR, pcgenOutputSheetDir.getText());
	PCGenSettings.OPTIONS_CONTEXT.setBoolean(PCGenSettings.OPTION_CREATE_PCG_BACKUP,
		pcgenCreateBackupCharacter.isSelected());
	PCGenSettings.getInstance().setProperty(PCGenSettings.BACKUP_PCG_PATH, pcgenBackupCharacterDir.getText());

	ConfigurationSettings.setSystemProperty(ConfigurationSettings.PREVIEW_DIR, pcgenPreviewDir.getText());
}