27
28 import java.util.regex.Pattern;
29
30 /**
31 * Use <code>Platform</code> to detect the operating system that is currently running.
32 *
33 * Example:
34 *
35 * Platform platform = Platform.getPlatform();
36 *
37 * switch(platform) {
38 * case Platform.MAC: {
39 * //TODO Do something
40 * break;
41 * }
42 * case Platform.WINDOWS:
43 * case Platform.LINUX: {
44 * //TODO Do something else
45 * }
46 * }
47 */
48
49 public enum Platform {UNKNOWN, WINDOWS, LINUX, MAC;
50 private static final Platform platform;
51 private static final int majorVersion;
52 private static final int minorVersion;
53
54 static {
55 String os = System.getProperty("os.name").toLowerCase();
56
57 if (os.indexOf("win") >= 0) {
58 platform = Platform.WINDOWS;
59 }
60 else if (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0) {
61 platform = Platform.LINUX;
62 }
63 else if (os.indexOf("mac") >= 0) {
64 platform = Platform.MAC;
65 }
66 else {
67 platform = Platform.UNKNOWN;
68 }
|
27
28 import java.util.regex.Pattern;
29
30 /**
31 * Use <code>Platform</code> to detect the operating system that is currently running.
32 *
33 * Example:
34 *
35 * Platform platform = Platform.getPlatform();
36 *
37 * switch(platform) {
38 * case Platform.MAC: {
39 * //TODO Do something
40 * break;
41 * }
42 * case Platform.WINDOWS:
43 * case Platform.LINUX: {
44 * //TODO Do something else
45 * }
46 * }
47 *
48 * @deprecated use {@link ToolProvider} to locate the {@code "javapackager"} tool instead.
49 */
50 @Deprecated(since="10", forRemoval=true)
51 public enum Platform {UNKNOWN, WINDOWS, LINUX, MAC;
52 private static final Platform platform;
53 private static final int majorVersion;
54 private static final int minorVersion;
55
56 static {
57 String os = System.getProperty("os.name").toLowerCase();
58
59 if (os.indexOf("win") >= 0) {
60 platform = Platform.WINDOWS;
61 }
62 else if (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0) {
63 platform = Platform.LINUX;
64 }
65 else if (os.indexOf("mac") >= 0) {
66 platform = Platform.MAC;
67 }
68 else {
69 platform = Platform.UNKNOWN;
70 }
|