Code example for Field

Methods: getInt, setAccessible

0
	 * @return 
	 */ 
	public static int getProcessId(Process process) { 
		try { 
			Field pidField = process.getClass().getDeclaredField("pid");
			pidField.setAccessible(true);
			return pidField.getInt(process);
		} catch (Exception ex) {
			return -1; 
		} 
	} 
 
	/** 
	 * Returns the process id of the current JVM, or -1 if we couldn't work it out. 
	 * @return 
	 */ 
	public static int getVmProcessId() { 
		try { 
			if (Platform.isMac()) { 
				// This only works if we were started with -Xdock, but that's true for our applications, and I don't have a better solution. 
				Map<String, String> env = System.getenv();