| 1 16 package org.apache.commons.lang; 17 18 import java.io.File ; 19 20 39 public class SystemUtils { 40 41 44 private static final String OS_NAME_WINDOWS_PREFIX = "Windows"; 45 46 50 53 private static final String USER_HOME_KEY = "user.home"; 54 55 58 private static final String USER_DIR_KEY = "user.dir"; 59 60 63 private static final String JAVA_IO_TMPDIR_KEY = "java.io.tmpdir"; 64 65 68 private static final String JAVA_HOME_KEY = "java.home"; 69 70 86 public static final String AWT_TOOLKIT = getSystemProperty("awt.toolkit"); 87 88 104 public static final String FILE_ENCODING = getSystemProperty("file.encoding"); 105 106 121 public static final String FILE_SEPARATOR = getSystemProperty("file.separator"); 122 123 137 public static final String JAVA_AWT_FONTS = getSystemProperty("java.awt.fonts"); 138 139 153 public static final String JAVA_AWT_GRAPHICSENV = getSystemProperty("java.awt.graphicsenv"); 154 155 174 public static final String JAVA_AWT_HEADLESS = getSystemProperty("java.awt.headless"); 175 176 190 public static final String JAVA_AWT_PRINTERJOB = getSystemProperty("java.awt.printerjob"); 191 192 206 public static final String JAVA_CLASS_PATH = getSystemProperty("java.class.path"); 207 208 223 public static final String JAVA_CLASS_VERSION = getSystemProperty("java.class.version"); 224 225 240 public static final String JAVA_COMPILER = getSystemProperty("java.compiler"); 241 242 257 public static final String JAVA_ENDORSED_DIRS = getSystemProperty("java.endorsed.dirs"); 258 259 274 public static final String JAVA_EXT_DIRS = getSystemProperty("java.ext.dirs"); 275 276 290 public static final String JAVA_HOME = getSystemProperty(JAVA_HOME_KEY); 291 292 306 public static final String JAVA_IO_TMPDIR = getSystemProperty(JAVA_IO_TMPDIR_KEY); 307 308 323 public static final String JAVA_LIBRARY_PATH = getSystemProperty("java.library.path"); 324 325 341 public static final String JAVA_RUNTIME_NAME = getSystemProperty("java.runtime.name"); 342 343 359 public static final String JAVA_RUNTIME_VERSION = getSystemProperty("java.runtime.version"); 360 361 376 public static final String JAVA_SPECIFICATION_NAME = getSystemProperty("java.specification.name"); 377 378 393 public static final String JAVA_SPECIFICATION_VENDOR = getSystemProperty("java.specification.vendor"); 394 395 410 public static final String JAVA_SPECIFICATION_VERSION = getSystemProperty("java.specification.version"); 411 412 427 public static final String JAVA_UTIL_PREFS_PREFERENCES_FACTORY = 428 getSystemProperty("java.util.prefs.PreferencesFactory"); 429 430 444 public static final String JAVA_VENDOR = getSystemProperty("java.vendor"); 445 446 460 public static final String JAVA_VENDOR_URL = getSystemProperty("java.vendor.url"); 461 462 476 public static final String JAVA_VERSION = getSystemProperty("java.version"); 477 478 494 public static final String JAVA_VM_INFO = getSystemProperty("java.vm.info"); 495 496 511 public static final String JAVA_VM_NAME = getSystemProperty("java.vm.name"); 512 513 528 public static final String JAVA_VM_SPECIFICATION_NAME = getSystemProperty("java.vm.specification.name"); 529 530 545 public static final String JAVA_VM_SPECIFICATION_VENDOR = getSystemProperty("java.vm.specification.vendor"); 546 547 562 public static final String JAVA_VM_SPECIFICATION_VERSION = getSystemProperty("java.vm.specification.version"); 563 564 579 public static final String JAVA_VM_VENDOR = getSystemProperty("java.vm.vendor"); 580 581 596 public static final String JAVA_VM_VERSION = getSystemProperty("java.vm.version"); 597 598 613 public static final String LINE_SEPARATOR = getSystemProperty("line.separator"); 614 615 629 public static final String OS_ARCH = getSystemProperty("os.arch"); 630 631 645 public static final String OS_NAME = getSystemProperty("os.name"); 646 647 661 public static final String OS_VERSION = getSystemProperty("os.version"); 662 663 678 public static final String PATH_SEPARATOR = getSystemProperty("path.separator"); 679 680 697 public static final String USER_COUNTRY = 698 (getSystemProperty("user.country") == null ? 699 getSystemProperty("user.region") : getSystemProperty("user.country")); 700 701 716 public static final String USER_DIR = getSystemProperty(USER_DIR_KEY); 717 718 732 public static final String USER_HOME = getSystemProperty(USER_HOME_KEY); 733 734 750 public static final String USER_LANGUAGE = getSystemProperty("user.language"); 751 752 766 public static final String USER_NAME = getSystemProperty("user.name"); 767 768 783 public static final String USER_TIMEZONE = getSystemProperty("user.timezone"); 784 785 790 797 public static final String JAVA_VERSION_TRIMMED = getJavaVersionTrimmed(); 798 799 804 817 public static final float JAVA_VERSION_FLOAT = getJavaVersionAsFloat(); 818 819 832 public static final int JAVA_VERSION_INT = getJavaVersionAsInt(); 833 834 839 845 public static final boolean IS_JAVA_1_1 = getJavaVersionMatches("1.1"); 846 847 853 public static final boolean IS_JAVA_1_2 = getJavaVersionMatches("1.2"); 854 855 861 public static final boolean IS_JAVA_1_3 = getJavaVersionMatches("1.3"); 862 863 869 public static final boolean IS_JAVA_1_4 = getJavaVersionMatches("1.4"); 870 871 877 public static final boolean IS_JAVA_1_5 = getJavaVersionMatches("1.5"); 878 879 887 895 public static final boolean IS_OS_AIX = getOSMatches("AIX"); 896 897 905 public static final boolean IS_OS_HP_UX = getOSMatches("HP-UX"); 906 907 915 public static final boolean IS_OS_IRIX = getOSMatches("Irix"); 916 917 925 public static final boolean IS_OS_LINUX = getOSMatches("Linux") || getOSMatches("LINUX"); 926 927 935 public static final boolean IS_OS_MAC = getOSMatches("Mac"); 936 937 945 public static final boolean IS_OS_MAC_OSX = getOSMatches("Mac OS X"); 946 947 955 public static final boolean IS_OS_OS2 = getOSMatches("OS/2"); 956 957 965 public static final boolean IS_OS_SOLARIS = getOSMatches("Solaris"); 966 967 975 public static final boolean IS_OS_SUN_OS = getOSMatches("SunOS"); 976 977 986
|