| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| SystemUtils |
|
| 2.625;2.625 |
| 1 | /* | |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE | |
| 3 | * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file | |
| 4 | * to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the | |
| 5 | * License. You may obtain a copy of the License at | |
| 6 | * | |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 | * | |
| 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | |
| 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | |
| 11 | * specific language governing permissions and limitations under the License. | |
| 12 | */ | |
| 13 | package liquibase.util; | |
| 14 | ||
| 15 | import java.io.File; | |
| 16 | ||
| 17 | /** | |
| 18 | * Code taken from <a href="http://commons.apache.org/lang">Commons lang utils</a> | |
| 19 | * <p> | |
| 20 | * Helpers for <code>java.lang.System</code>. | |
| 21 | * </p> | |
| 22 | * | |
| 23 | * <p> | |
| 24 | * If a system property cannot be read due to security restrictions, the corresponding field in this class will be set | |
| 25 | * to <code>null</code> and a message will be written to <code>System.err</code>. | |
| 26 | * </p> | |
| 27 | * | |
| 28 | * @author Apache Software Foundation | |
| 29 | * @author Based on code from Avalon Excalibur | |
| 30 | * @author Based on code from Lucene | |
| 31 | * @author <a href="mailto:sdowney@panix.com">Steve Downey</a> | |
| 32 | * @author Gary Gregory | |
| 33 | * @author Michael Becke | |
| 34 | * @author Tetsuya Kaneuchi | |
| 35 | * @author Rafal Krupinski | |
| 36 | * @author Jason Gritman | |
| 37 | * @since 1.0 | |
| 38 | * @version $Id: SystemUtils.java 905707 2010-02-02 16:59:59Z niallp $ | |
| 39 | */ | |
| 40 | public class SystemUtils { | |
| 41 | ||
| 42 | /** | |
| 43 | * The prefix String for all Windows OS. | |
| 44 | */ | |
| 45 | private static final String OS_NAME_WINDOWS_PREFIX = "Windows"; | |
| 46 | ||
| 47 | // System property constants | |
| 48 | // ----------------------------------------------------------------------- | |
| 49 | // These MUST be declared first. Other constants depend on this. | |
| 50 | ||
| 51 | /** | |
| 52 | * The System property key for the user home directory. | |
| 53 | */ | |
| 54 | private static final String USER_HOME_KEY = "user.home"; | |
| 55 | ||
| 56 | /** | |
| 57 | * The System property key for the user directory. | |
| 58 | */ | |
| 59 | private static final String USER_DIR_KEY = "user.dir"; | |
| 60 | ||
| 61 | /** | |
| 62 | * The System property key for the Java IO temporary directory. | |
| 63 | */ | |
| 64 | private static final String JAVA_IO_TMPDIR_KEY = "java.io.tmpdir"; | |
| 65 | ||
| 66 | /** | |
| 67 | * The System property key for the Java home directory. | |
| 68 | */ | |
| 69 | private static final String JAVA_HOME_KEY = "java.home"; | |
| 70 | ||
| 71 | /** | |
| 72 | * <p> | |
| 73 | * The <code>awt.toolkit</code> System Property. | |
| 74 | * </p> | |
| 75 | * <p> | |
| 76 | * Holds a class name, on Windows XP this is <code>sun.awt.windows.WToolkit</code>. | |
| 77 | * </p> | |
| 78 | * <p> | |
| 79 | * <b>On platforms without a GUI, this value is <code>null</code>.</b> | |
| 80 | * </p> | |
| 81 | * | |
| 82 | * <p> | |
| 83 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 84 | * does not exist. | |
| 85 | * </p> | |
| 86 | * | |
| 87 | * <p> | |
| 88 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 89 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 90 | * sync with that System property. | |
| 91 | * </p> | |
| 92 | * | |
| 93 | * @since 2.1 | |
| 94 | */ | |
| 95 | 0 | public static final String AWT_TOOLKIT = getSystemProperty("awt.toolkit"); |
| 96 | ||
| 97 | /** | |
| 98 | * <p> | |
| 99 | * The <code>file.encoding</code> System Property. | |
| 100 | * </p> | |
| 101 | * <p> | |
| 102 | * File encoding, such as <code>Cp1252</code>. | |
| 103 | * </p> | |
| 104 | * | |
| 105 | * <p> | |
| 106 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 107 | * does not exist. | |
| 108 | * </p> | |
| 109 | * | |
| 110 | * <p> | |
| 111 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 112 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 113 | * sync with that System property. | |
| 114 | * </p> | |
| 115 | * | |
| 116 | * @since 2.0 | |
| 117 | * @since Java 1.2 | |
| 118 | */ | |
| 119 | 0 | public static final String FILE_ENCODING = getSystemProperty("file.encoding"); |
| 120 | ||
| 121 | /** | |
| 122 | * <p> | |
| 123 | * The <code>file.separator</code> System Property. File separator (<code>"/"</code> on UNIX). | |
| 124 | * </p> | |
| 125 | * | |
| 126 | * <p> | |
| 127 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 128 | * does not exist. | |
| 129 | * </p> | |
| 130 | * | |
| 131 | * <p> | |
| 132 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 133 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 134 | * sync with that System property. | |
| 135 | * </p> | |
| 136 | * | |
| 137 | * @since Java 1.1 | |
| 138 | */ | |
| 139 | 0 | public static final String FILE_SEPARATOR = getSystemProperty("file.separator"); |
| 140 | ||
| 141 | /** | |
| 142 | * <p> | |
| 143 | * The <code>java.awt.fonts</code> System Property. | |
| 144 | * </p> | |
| 145 | * | |
| 146 | * <p> | |
| 147 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 148 | * does not exist. | |
| 149 | * </p> | |
| 150 | * | |
| 151 | * <p> | |
| 152 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 153 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 154 | * sync with that System property. | |
| 155 | * </p> | |
| 156 | * | |
| 157 | * @since 2.1 | |
| 158 | */ | |
| 159 | 0 | public static final String JAVA_AWT_FONTS = getSystemProperty("java.awt.fonts"); |
| 160 | ||
| 161 | /** | |
| 162 | * <p> | |
| 163 | * The <code>java.awt.graphicsenv</code> System Property. | |
| 164 | * </p> | |
| 165 | * | |
| 166 | * <p> | |
| 167 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 168 | * does not exist. | |
| 169 | * </p> | |
| 170 | * | |
| 171 | * <p> | |
| 172 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 173 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 174 | * sync with that System property. | |
| 175 | * </p> | |
| 176 | * | |
| 177 | * @since 2.1 | |
| 178 | */ | |
| 179 | 0 | public static final String JAVA_AWT_GRAPHICSENV = getSystemProperty("java.awt.graphicsenv"); |
| 180 | ||
| 181 | /** | |
| 182 | * <p> | |
| 183 | * The <code>java.awt.headless</code> System Property. The value of this property is the String <code>"true"</code> | |
| 184 | * or <code>"false"</code>. | |
| 185 | * </p> | |
| 186 | * | |
| 187 | * <p> | |
| 188 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 189 | * does not exist. | |
| 190 | * </p> | |
| 191 | * | |
| 192 | * <p> | |
| 193 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 194 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 195 | * sync with that System property. | |
| 196 | * </p> | |
| 197 | * | |
| 198 | * @see #isJavaAwtHeadless() | |
| 199 | * @since 2.1 | |
| 200 | * @since Java 1.4 | |
| 201 | */ | |
| 202 | 0 | public static final String JAVA_AWT_HEADLESS = getSystemProperty("java.awt.headless"); |
| 203 | ||
| 204 | /** | |
| 205 | * <p> | |
| 206 | * The <code>java.awt.printerjob</code> System Property. | |
| 207 | * </p> | |
| 208 | * | |
| 209 | * <p> | |
| 210 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 211 | * does not exist. | |
| 212 | * </p> | |
| 213 | * | |
| 214 | * <p> | |
| 215 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 216 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 217 | * sync with that System property. | |
| 218 | * </p> | |
| 219 | * | |
| 220 | * @since 2.1 | |
| 221 | */ | |
| 222 | 0 | public static final String JAVA_AWT_PRINTERJOB = getSystemProperty("java.awt.printerjob"); |
| 223 | ||
| 224 | /** | |
| 225 | * <p> | |
| 226 | * The <code>java.class.path</code> System Property. Java class path. | |
| 227 | * </p> | |
| 228 | * | |
| 229 | * <p> | |
| 230 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 231 | * does not exist. | |
| 232 | * </p> | |
| 233 | * | |
| 234 | * <p> | |
| 235 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 236 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 237 | * sync with that System property. | |
| 238 | * </p> | |
| 239 | * | |
| 240 | * @since Java 1.1 | |
| 241 | */ | |
| 242 | 0 | public static final String JAVA_CLASS_PATH = getSystemProperty("java.class.path"); |
| 243 | ||
| 244 | /** | |
| 245 | * <p> | |
| 246 | * The <code>java.class.version</code> System Property. Java class format version number. | |
| 247 | * </p> | |
| 248 | * | |
| 249 | * <p> | |
| 250 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 251 | * does not exist. | |
| 252 | * </p> | |
| 253 | * | |
| 254 | * <p> | |
| 255 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 256 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 257 | * sync with that System property. | |
| 258 | * </p> | |
| 259 | * | |
| 260 | * @since Java 1.1 | |
| 261 | */ | |
| 262 | 0 | public static final String JAVA_CLASS_VERSION = getSystemProperty("java.class.version"); |
| 263 | ||
| 264 | /** | |
| 265 | * <p> | |
| 266 | * The <code>java.compiler</code> System Property. Name of JIT compiler to use. First in JDK version 1.2. Not used | |
| 267 | * in Sun JDKs after 1.2. | |
| 268 | * </p> | |
| 269 | * | |
| 270 | * <p> | |
| 271 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 272 | * does not exist. | |
| 273 | * </p> | |
| 274 | * | |
| 275 | * <p> | |
| 276 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 277 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 278 | * sync with that System property. | |
| 279 | * </p> | |
| 280 | * | |
| 281 | * @since Java 1.2. Not used in Sun versions after 1.2. | |
| 282 | */ | |
| 283 | 0 | public static final String JAVA_COMPILER = getSystemProperty("java.compiler"); |
| 284 | ||
| 285 | /** | |
| 286 | * <p> | |
| 287 | * The <code>java.endorsed.dirs</code> System Property. Path of endorsed directory or directories. | |
| 288 | * </p> | |
| 289 | * | |
| 290 | * <p> | |
| 291 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 292 | * does not exist. | |
| 293 | * </p> | |
| 294 | * | |
| 295 | * <p> | |
| 296 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 297 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 298 | * sync with that System property. | |
| 299 | * </p> | |
| 300 | * | |
| 301 | * @since Java 1.4 | |
| 302 | */ | |
| 303 | 0 | public static final String JAVA_ENDORSED_DIRS = getSystemProperty("java.endorsed.dirs"); |
| 304 | ||
| 305 | /** | |
| 306 | * <p> | |
| 307 | * The <code>java.ext.dirs</code> System Property. Path of extension directory or directories. | |
| 308 | * </p> | |
| 309 | * | |
| 310 | * <p> | |
| 311 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 312 | * does not exist. | |
| 313 | * </p> | |
| 314 | * | |
| 315 | * <p> | |
| 316 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 317 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 318 | * sync with that System property. | |
| 319 | * </p> | |
| 320 | * | |
| 321 | * @since Java 1.3 | |
| 322 | */ | |
| 323 | 0 | public static final String JAVA_EXT_DIRS = getSystemProperty("java.ext.dirs"); |
| 324 | ||
| 325 | /** | |
| 326 | * <p> | |
| 327 | * The <code>java.home</code> System Property. Java installation directory. | |
| 328 | * </p> | |
| 329 | * | |
| 330 | * <p> | |
| 331 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 332 | * does not exist. | |
| 333 | * </p> | |
| 334 | * | |
| 335 | * <p> | |
| 336 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 337 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 338 | * sync with that System property. | |
| 339 | * </p> | |
| 340 | * | |
| 341 | * @since Java 1.1 | |
| 342 | */ | |
| 343 | 0 | public static final String JAVA_HOME = getSystemProperty(JAVA_HOME_KEY); |
| 344 | ||
| 345 | /** | |
| 346 | * <p> | |
| 347 | * The <code>java.io.tmpdir</code> System Property. Default temp file path. | |
| 348 | * </p> | |
| 349 | * | |
| 350 | * <p> | |
| 351 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 352 | * does not exist. | |
| 353 | * </p> | |
| 354 | * | |
| 355 | * <p> | |
| 356 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 357 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 358 | * sync with that System property. | |
| 359 | * </p> | |
| 360 | * | |
| 361 | * @since Java 1.2 | |
| 362 | */ | |
| 363 | 0 | public static final String JAVA_IO_TMPDIR = getSystemProperty(JAVA_IO_TMPDIR_KEY); |
| 364 | ||
| 365 | /** | |
| 366 | * <p> | |
| 367 | * The <code>java.library.path</code> System Property. List of paths to search when loading libraries. | |
| 368 | * </p> | |
| 369 | * | |
| 370 | * <p> | |
| 371 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 372 | * does not exist. | |
| 373 | * </p> | |
| 374 | * | |
| 375 | * <p> | |
| 376 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 377 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 378 | * sync with that System property. | |
| 379 | * </p> | |
| 380 | * | |
| 381 | * @since Java 1.2 | |
| 382 | */ | |
| 383 | 0 | public static final String JAVA_LIBRARY_PATH = getSystemProperty("java.library.path"); |
| 384 | ||
| 385 | /** | |
| 386 | * <p> | |
| 387 | * The <code>java.runtime.name</code> System Property. Java Runtime Environment name. | |
| 388 | * </p> | |
| 389 | * | |
| 390 | * <p> | |
| 391 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 392 | * does not exist. | |
| 393 | * </p> | |
| 394 | * | |
| 395 | * <p> | |
| 396 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 397 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 398 | * sync with that System property. | |
| 399 | * </p> | |
| 400 | * | |
| 401 | * @since 2.0 | |
| 402 | * @since Java 1.3 | |
| 403 | */ | |
| 404 | 0 | public static final String JAVA_RUNTIME_NAME = getSystemProperty("java.runtime.name"); |
| 405 | ||
| 406 | /** | |
| 407 | * <p> | |
| 408 | * The <code>java.runtime.version</code> System Property. Java Runtime Environment version. | |
| 409 | * </p> | |
| 410 | * | |
| 411 | * <p> | |
| 412 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 413 | * does not exist. | |
| 414 | * </p> | |
| 415 | * | |
| 416 | * <p> | |
| 417 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 418 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 419 | * sync with that System property. | |
| 420 | * </p> | |
| 421 | * | |
| 422 | * @since 2.0 | |
| 423 | * @since Java 1.3 | |
| 424 | */ | |
| 425 | 0 | public static final String JAVA_RUNTIME_VERSION = getSystemProperty("java.runtime.version"); |
| 426 | ||
| 427 | /** | |
| 428 | * <p> | |
| 429 | * The <code>java.specification.name</code> System Property. Java Runtime Environment specification name. | |
| 430 | * </p> | |
| 431 | * | |
| 432 | * <p> | |
| 433 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 434 | * does not exist. | |
| 435 | * </p> | |
| 436 | * | |
| 437 | * <p> | |
| 438 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 439 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 440 | * sync with that System property. | |
| 441 | * </p> | |
| 442 | * | |
| 443 | * @since Java 1.2 | |
| 444 | */ | |
| 445 | 0 | public static final String JAVA_SPECIFICATION_NAME = getSystemProperty("java.specification.name"); |
| 446 | ||
| 447 | /** | |
| 448 | * <p> | |
| 449 | * The <code>java.specification.vendor</code> System Property. Java Runtime Environment specification vendor. | |
| 450 | * </p> | |
| 451 | * | |
| 452 | * <p> | |
| 453 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 454 | * does not exist. | |
| 455 | * </p> | |
| 456 | * | |
| 457 | * <p> | |
| 458 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 459 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 460 | * sync with that System property. | |
| 461 | * </p> | |
| 462 | * | |
| 463 | * @since Java 1.2 | |
| 464 | */ | |
| 465 | 0 | public static final String JAVA_SPECIFICATION_VENDOR = getSystemProperty("java.specification.vendor"); |
| 466 | ||
| 467 | /** | |
| 468 | * <p> | |
| 469 | * The <code>java.specification.version</code> System Property. Java Runtime Environment specification version. | |
| 470 | * </p> | |
| 471 | * | |
| 472 | * <p> | |
| 473 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 474 | * does not exist. | |
| 475 | * </p> | |
| 476 | * | |
| 477 | * <p> | |
| 478 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 479 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 480 | * sync with that System property. | |
| 481 | * </p> | |
| 482 | * | |
| 483 | * @since Java 1.3 | |
| 484 | */ | |
| 485 | 0 | public static final String JAVA_SPECIFICATION_VERSION = getSystemProperty("java.specification.version"); |
| 486 | ||
| 487 | /** | |
| 488 | * <p> | |
| 489 | * The <code>java.util.prefs.PreferencesFactory</code> System Property. A class name. | |
| 490 | * </p> | |
| 491 | * | |
| 492 | * <p> | |
| 493 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 494 | * does not exist. | |
| 495 | * </p> | |
| 496 | * | |
| 497 | * <p> | |
| 498 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 499 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 500 | * sync with that System property. | |
| 501 | * </p> | |
| 502 | * | |
| 503 | * @since 2.1 | |
| 504 | * @since Java 1.4 | |
| 505 | */ | |
| 506 | 0 | public static final String JAVA_UTIL_PREFS_PREFERENCES_FACTORY = getSystemProperty("java.util.prefs.PreferencesFactory"); |
| 507 | ||
| 508 | /** | |
| 509 | * <p> | |
| 510 | * The <code>java.vendor</code> System Property. Java vendor-specific string. | |
| 511 | * </p> | |
| 512 | * | |
| 513 | * <p> | |
| 514 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 515 | * does not exist. | |
| 516 | * </p> | |
| 517 | * | |
| 518 | * <p> | |
| 519 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 520 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 521 | * sync with that System property. | |
| 522 | * </p> | |
| 523 | * | |
| 524 | * @since Java 1.1 | |
| 525 | */ | |
| 526 | 0 | public static final String JAVA_VENDOR = getSystemProperty("java.vendor"); |
| 527 | ||
| 528 | /** | |
| 529 | * <p> | |
| 530 | * The <code>java.vendor.url</code> System Property. Java vendor URL. | |
| 531 | * </p> | |
| 532 | * | |
| 533 | * <p> | |
| 534 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 535 | * does not exist. | |
| 536 | * </p> | |
| 537 | * | |
| 538 | * <p> | |
| 539 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 540 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 541 | * sync with that System property. | |
| 542 | * </p> | |
| 543 | * | |
| 544 | * @since Java 1.1 | |
| 545 | */ | |
| 546 | 0 | public static final String JAVA_VENDOR_URL = getSystemProperty("java.vendor.url"); |
| 547 | ||
| 548 | /** | |
| 549 | * <p> | |
| 550 | * The <code>java.version</code> System Property. Java version number. | |
| 551 | * </p> | |
| 552 | * | |
| 553 | * <p> | |
| 554 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 555 | * does not exist. | |
| 556 | * </p> | |
| 557 | * | |
| 558 | * <p> | |
| 559 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 560 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 561 | * sync with that System property. | |
| 562 | * </p> | |
| 563 | * | |
| 564 | * @since Java 1.1 | |
| 565 | */ | |
| 566 | 0 | public static final String JAVA_VERSION = getSystemProperty("java.version"); |
| 567 | ||
| 568 | /** | |
| 569 | * <p> | |
| 570 | * The <code>java.vm.info</code> System Property. Java Virtual Machine implementation info. | |
| 571 | * </p> | |
| 572 | * | |
| 573 | * <p> | |
| 574 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 575 | * does not exist. | |
| 576 | * </p> | |
| 577 | * | |
| 578 | * <p> | |
| 579 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 580 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 581 | * sync with that System property. | |
| 582 | * </p> | |
| 583 | * | |
| 584 | * @since 2.0 | |
| 585 | * @since Java 1.2 | |
| 586 | */ | |
| 587 | 0 | public static final String JAVA_VM_INFO = getSystemProperty("java.vm.info"); |
| 588 | ||
| 589 | /** | |
| 590 | * <p> | |
| 591 | * The <code>java.vm.name</code> System Property. Java Virtual Machine implementation name. | |
| 592 | * </p> | |
| 593 | * | |
| 594 | * <p> | |
| 595 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 596 | * does not exist. | |
| 597 | * </p> | |
| 598 | * | |
| 599 | * <p> | |
| 600 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 601 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 602 | * sync with that System property. | |
| 603 | * </p> | |
| 604 | * | |
| 605 | * @since Java 1.2 | |
| 606 | */ | |
| 607 | 0 | public static final String JAVA_VM_NAME = getSystemProperty("java.vm.name"); |
| 608 | ||
| 609 | /** | |
| 610 | * <p> | |
| 611 | * The <code>java.vm.specification.name</code> System Property. Java Virtual Machine specification name. | |
| 612 | * </p> | |
| 613 | * | |
| 614 | * <p> | |
| 615 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 616 | * does not exist. | |
| 617 | * </p> | |
| 618 | * | |
| 619 | * <p> | |
| 620 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 621 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 622 | * sync with that System property. | |
| 623 | * </p> | |
| 624 | * | |
| 625 | * @since Java 1.2 | |
| 626 | */ | |
| 627 | 0 | public static final String JAVA_VM_SPECIFICATION_NAME = getSystemProperty("java.vm.specification.name"); |
| 628 | ||
| 629 | /** | |
| 630 | * <p> | |
| 631 | * The <code>java.vm.specification.vendor</code> System Property. Java Virtual Machine specification vendor. | |
| 632 | * </p> | |
| 633 | * | |
| 634 | * <p> | |
| 635 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 636 | * does not exist. | |
| 637 | * </p> | |
| 638 | * | |
| 639 | * <p> | |
| 640 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 641 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 642 | * sync with that System property. | |
| 643 | * </p> | |
| 644 | * | |
| 645 | * @since Java 1.2 | |
| 646 | */ | |
| 647 | 0 | public static final String JAVA_VM_SPECIFICATION_VENDOR = getSystemProperty("java.vm.specification.vendor"); |
| 648 | ||
| 649 | /** | |
| 650 | * <p> | |
| 651 | * The <code>java.vm.specification.version</code> System Property. Java Virtual Machine specification version. | |
| 652 | * </p> | |
| 653 | * | |
| 654 | * <p> | |
| 655 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 656 | * does not exist. | |
| 657 | * </p> | |
| 658 | * | |
| 659 | * <p> | |
| 660 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 661 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 662 | * sync with that System property. | |
| 663 | * </p> | |
| 664 | * | |
| 665 | * @since Java 1.2 | |
| 666 | */ | |
| 667 | 0 | public static final String JAVA_VM_SPECIFICATION_VERSION = getSystemProperty("java.vm.specification.version"); |
| 668 | ||
| 669 | /** | |
| 670 | * <p> | |
| 671 | * The <code>java.vm.vendor</code> System Property. Java Virtual Machine implementation vendor. | |
| 672 | * </p> | |
| 673 | * | |
| 674 | * <p> | |
| 675 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 676 | * does not exist. | |
| 677 | * </p> | |
| 678 | * | |
| 679 | * <p> | |
| 680 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 681 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 682 | * sync with that System property. | |
| 683 | * </p> | |
| 684 | * | |
| 685 | * @since Java 1.2 | |
| 686 | */ | |
| 687 | 0 | public static final String JAVA_VM_VENDOR = getSystemProperty("java.vm.vendor"); |
| 688 | ||
| 689 | /** | |
| 690 | * <p> | |
| 691 | * The <code>java.vm.version</code> System Property. Java Virtual Machine implementation version. | |
| 692 | * </p> | |
| 693 | * | |
| 694 | * <p> | |
| 695 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 696 | * does not exist. | |
| 697 | * </p> | |
| 698 | * | |
| 699 | * <p> | |
| 700 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 701 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 702 | * sync with that System property. | |
| 703 | * </p> | |
| 704 | * | |
| 705 | * @since Java 1.2 | |
| 706 | */ | |
| 707 | 0 | public static final String JAVA_VM_VERSION = getSystemProperty("java.vm.version"); |
| 708 | ||
| 709 | /** | |
| 710 | * <p> | |
| 711 | * The <code>line.separator</code> System Property. Line separator (<code>"\n"</code> on UNIX). | |
| 712 | * </p> | |
| 713 | * | |
| 714 | * <p> | |
| 715 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 716 | * does not exist. | |
| 717 | * </p> | |
| 718 | * | |
| 719 | * <p> | |
| 720 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 721 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 722 | * sync with that System property. | |
| 723 | * </p> | |
| 724 | * | |
| 725 | * @since Java 1.1 | |
| 726 | */ | |
| 727 | 0 | public static final String LINE_SEPARATOR = getSystemProperty("line.separator"); |
| 728 | ||
| 729 | /** | |
| 730 | * <p> | |
| 731 | * The <code>os.arch</code> System Property. Operating system architecture. | |
| 732 | * </p> | |
| 733 | * | |
| 734 | * <p> | |
| 735 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 736 | * does not exist. | |
| 737 | * </p> | |
| 738 | * | |
| 739 | * <p> | |
| 740 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 741 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 742 | * sync with that System property. | |
| 743 | * </p> | |
| 744 | * | |
| 745 | * @since Java 1.1 | |
| 746 | */ | |
| 747 | 0 | public static final String OS_ARCH = getSystemProperty("os.arch"); |
| 748 | ||
| 749 | /** | |
| 750 | * <p> | |
| 751 | * The <code>os.name</code> System Property. Operating system name. | |
| 752 | * </p> | |
| 753 | * | |
| 754 | * <p> | |
| 755 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 756 | * does not exist. | |
| 757 | * </p> | |
| 758 | * | |
| 759 | * <p> | |
| 760 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 761 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 762 | * sync with that System property. | |
| 763 | * </p> | |
| 764 | * | |
| 765 | * @since Java 1.1 | |
| 766 | */ | |
| 767 | 0 | public static final String OS_NAME = getSystemProperty("os.name"); |
| 768 | ||
| 769 | /** | |
| 770 | * <p> | |
| 771 | * The <code>os.version</code> System Property. Operating system version. | |
| 772 | * </p> | |
| 773 | * | |
| 774 | * <p> | |
| 775 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 776 | * does not exist. | |
| 777 | * </p> | |
| 778 | * | |
| 779 | * <p> | |
| 780 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 781 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 782 | * sync with that System property. | |
| 783 | * </p> | |
| 784 | * | |
| 785 | * @since Java 1.1 | |
| 786 | */ | |
| 787 | 0 | public static final String OS_VERSION = getSystemProperty("os.version"); |
| 788 | ||
| 789 | /** | |
| 790 | * <p> | |
| 791 | * The <code>path.separator</code> System Property. Path separator (<code>":"</code> on UNIX). | |
| 792 | * </p> | |
| 793 | * | |
| 794 | * <p> | |
| 795 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 796 | * does not exist. | |
| 797 | * </p> | |
| 798 | * | |
| 799 | * <p> | |
| 800 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 801 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 802 | * sync with that System property. | |
| 803 | * </p> | |
| 804 | * | |
| 805 | * @since Java 1.1 | |
| 806 | */ | |
| 807 | 0 | public static final String PATH_SEPARATOR = getSystemProperty("path.separator"); |
| 808 | ||
| 809 | /** | |
| 810 | * <p> | |
| 811 | * The <code>user.country</code> or <code>user.region</code> System Property. User's country code, such as | |
| 812 | * <code>GB</code>. First in JDK version 1.2 as <code>user.region</code>. Renamed to <code>user.country</code> in | |
| 813 | * 1.4 | |
| 814 | * </p> | |
| 815 | * | |
| 816 | * <p> | |
| 817 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 818 | * does not exist. | |
| 819 | * </p> | |
| 820 | * | |
| 821 | * <p> | |
| 822 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 823 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 824 | * sync with that System property. | |
| 825 | * </p> | |
| 826 | * | |
| 827 | * @since 2.0 | |
| 828 | * @since Java 1.2 | |
| 829 | */ | |
| 830 | 0 | public static final String USER_COUNTRY = getSystemProperty("user.country") == null ? getSystemProperty("user.region") |
| 831 | : getSystemProperty("user.country"); | |
| 832 | ||
| 833 | /** | |
| 834 | * <p> | |
| 835 | * The <code>user.dir</code> System Property. User's current working directory. | |
| 836 | * </p> | |
| 837 | * | |
| 838 | * <p> | |
| 839 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 840 | * does not exist. | |
| 841 | * </p> | |
| 842 | * | |
| 843 | * <p> | |
| 844 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 845 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 846 | * sync with that System property. | |
| 847 | * </p> | |
| 848 | * | |
| 849 | * @since Java 1.1 | |
| 850 | */ | |
| 851 | 0 | public static final String USER_DIR = getSystemProperty(USER_DIR_KEY); |
| 852 | ||
| 853 | /** | |
| 854 | * <p> | |
| 855 | * The <code>user.home</code> System Property. User's home directory. | |
| 856 | * </p> | |
| 857 | * | |
| 858 | * <p> | |
| 859 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 860 | * does not exist. | |
| 861 | * </p> | |
| 862 | * | |
| 863 | * <p> | |
| 864 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 865 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 866 | * sync with that System property. | |
| 867 | * </p> | |
| 868 | * | |
| 869 | * @since Java 1.1 | |
| 870 | */ | |
| 871 | 0 | public static final String USER_HOME = getSystemProperty(USER_HOME_KEY); |
| 872 | ||
| 873 | /** | |
| 874 | * <p> | |
| 875 | * The <code>user.language</code> System Property. User's language code, such as <code>"en"</code>. | |
| 876 | * </p> | |
| 877 | * | |
| 878 | * <p> | |
| 879 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 880 | * does not exist. | |
| 881 | * </p> | |
| 882 | * | |
| 883 | * <p> | |
| 884 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 885 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 886 | * sync with that System property. | |
| 887 | * </p> | |
| 888 | * | |
| 889 | * @since 2.0 | |
| 890 | * @since Java 1.2 | |
| 891 | */ | |
| 892 | 0 | public static final String USER_LANGUAGE = getSystemProperty("user.language"); |
| 893 | ||
| 894 | /** | |
| 895 | * <p> | |
| 896 | * The <code>user.name</code> System Property. User's account name. | |
| 897 | * </p> | |
| 898 | * | |
| 899 | * <p> | |
| 900 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 901 | * does not exist. | |
| 902 | * </p> | |
| 903 | * | |
| 904 | * <p> | |
| 905 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 906 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 907 | * sync with that System property. | |
| 908 | * </p> | |
| 909 | * | |
| 910 | * @since Java 1.1 | |
| 911 | */ | |
| 912 | 0 | public static final String USER_NAME = getSystemProperty("user.name"); |
| 913 | ||
| 914 | /** | |
| 915 | * <p> | |
| 916 | * The <code>user.timezone</code> System Property. For example: <code>"America/Los_Angeles"</code>. | |
| 917 | * </p> | |
| 918 | * | |
| 919 | * <p> | |
| 920 | * Defaults to <code>null</code> if the runtime does not have security access to read this property or the property | |
| 921 | * does not exist. | |
| 922 | * </p> | |
| 923 | * | |
| 924 | * <p> | |
| 925 | * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or | |
| 926 | * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of | |
| 927 | * sync with that System property. | |
| 928 | * </p> | |
| 929 | * | |
| 930 | * @since 2.1 | |
| 931 | */ | |
| 932 | 0 | public static final String USER_TIMEZONE = getSystemProperty("user.timezone"); |
| 933 | ||
| 934 | // Java version | |
| 935 | // ----------------------------------------------------------------------- | |
| 936 | // This MUST be declared after those above as it depends on the | |
| 937 | // values being set up | |
| 938 | ||
| 939 | /** | |
| 940 | * <p> | |
| 941 | * Gets the Java version as a <code>String</code> trimming leading letters. | |
| 942 | * </p> | |
| 943 | * | |
| 944 | * <p> | |
| 945 | * The field will return <code>null</code> if {@link #JAVA_VERSION} is <code>null</code>. | |
| 946 | * </p> | |
| 947 | * | |
| 948 | * @since 2.1 | |
| 949 | */ | |
| 950 | 0 | public static final String JAVA_VERSION_TRIMMED = getJavaVersionTrimmed(); |
| 951 | ||
| 952 | // Java version values | |
| 953 | // ----------------------------------------------------------------------- | |
| 954 | // These MUST be declared after the trim above as they depend on the | |
| 955 | // value being set up | |
| 956 | ||
| 957 | /** | |
| 958 | * <p> | |
| 959 | * Gets the Java version as a <code>float</code>. | |
| 960 | * </p> | |
| 961 | * | |
| 962 | * <p> | |
| 963 | * Example return values: | |
| 964 | * </p> | |
| 965 | * <ul> | |
| 966 | * <li><code>1.2f</code> for JDK 1.2 | |
| 967 | * <li><code>1.31f</code> for JDK 1.3.1 | |
| 968 | * </ul> | |
| 969 | * | |
| 970 | * <p> | |
| 971 | * The field will return zero if {@link #JAVA_VERSION} is <code>null</code>. | |
| 972 | * </p> | |
| 973 | * | |
| 974 | * @since 2.0 | |
| 975 | */ | |
| 976 | 0 | public static final float JAVA_VERSION_FLOAT = getJavaVersionAsFloat(); |
| 977 | ||
| 978 | /** | |
| 979 | * <p> | |
| 980 | * Gets the Java version as an <code>int</code>. | |
| 981 | * </p> | |
| 982 | * | |
| 983 | * <p> | |
| 984 | * Example return values: | |
| 985 | * </p> | |
| 986 | * <ul> | |
| 987 | * <li><code>120</code> for JDK 1.2 | |
| 988 | * <li><code>131</code> for JDK 1.3.1 | |
| 989 | * </ul> | |
| 990 | * | |
| 991 | * <p> | |
| 992 | * The field will return zero if {@link #JAVA_VERSION} is <code>null</code>. | |
| 993 | * </p> | |
| 994 | * | |
| 995 | * @since 2.0 | |
| 996 | */ | |
| 997 | 0 | public static final int JAVA_VERSION_INT = getJavaVersionAsInt(); |
| 998 | ||
| 999 | // Java version checks | |
| 1000 | // ----------------------------------------------------------------------- | |
| 1001 | // These MUST be declared after those above as they depend on the | |
| 1002 | // values being set up | |
| 1003 | ||
| 1004 | /** | |
| 1005 | * <p> | |
| 1006 | * Is <code>true</code> if this is Java version 1.1 (also 1.1.x versions). | |
| 1007 | * </p> | |
| 1008 | * | |
| 1009 | * <p> | |
| 1010 | * The field will return <code>false</code> if {@link #JAVA_VERSION} is <code>null</code>. | |
| 1011 | * </p> | |
| 1012 | */ | |
| 1013 | 0 | public static final boolean IS_JAVA_1_1 = getJavaVersionMatches("1.1"); |
| 1014 | ||
| 1015 | /** | |
| 1016 | * <p> | |
| 1017 | * Is <code>true</code> if this is Java version 1.2 (also 1.2.x versions). | |
| 1018 | * </p> | |
| 1019 | * | |
| 1020 | * <p> | |
| 1021 | * The field will return <code>false</code> if {@link #JAVA_VERSION} is <code>null</code>. | |
| 1022 | * </p> | |
| 1023 | */ | |
| 1024 | 0 | public static final boolean IS_JAVA_1_2 = getJavaVersionMatches("1.2"); |
| 1025 | ||
| 1026 | /** | |
| 1027 | * <p> | |
| 1028 | * Is <code>true</code> if this is Java version 1.3 (also 1.3.x versions). | |
| 1029 | * </p> | |
| 1030 | * | |
| 1031 | * <p> | |
| 1032 | * The field will return <code>false</code> if {@link #JAVA_VERSION} is <code>null</code>. | |
| 1033 | * </p> | |
| 1034 | */ | |
| 1035 | 0 | public static final boolean IS_JAVA_1_3 = getJavaVersionMatches("1.3"); |
| 1036 | ||
| 1037 | /** | |
| 1038 | * <p> | |
| 1039 | * Is <code>true</code> if this is Java version 1.4 (also 1.4.x versions). | |
| 1040 | * </p> | |
| 1041 | * | |
| 1042 | * <p> | |
| 1043 | * The field will return <code>false</code> if {@link #JAVA_VERSION} is <code>null</code>. | |
| 1044 | * </p> | |
| 1045 | */ | |
| 1046 | 0 | public static final boolean IS_JAVA_1_4 = getJavaVersionMatches("1.4"); |
| 1047 | ||
| 1048 | /** | |
| 1049 | * <p> | |
| 1050 | * Is <code>true</code> if this is Java version 1.5 (also 1.5.x versions). | |
| 1051 | * </p> | |
| 1052 | * | |
| 1053 | * <p> | |
| 1054 | * The field will return <code>false</code> if {@link #JAVA_VERSION} is <code>null</code>. | |
| 1055 | * </p> | |
| 1056 | */ | |
| 1057 | 0 | public static final boolean IS_JAVA_1_5 = getJavaVersionMatches("1.5"); |
| 1058 | ||
| 1059 | /** | |
| 1060 | * <p> | |
| 1061 | * Is <code>true</code> if this is Java version 1.6 (also 1.6.x versions). | |
| 1062 | * </p> | |
| 1063 | * | |
| 1064 | * <p> | |
| 1065 | * The field will return <code>false</code> if {@link #JAVA_VERSION} is <code>null</code>. | |
| 1066 | * </p> | |
| 1067 | */ | |
| 1068 | 0 | public static final boolean IS_JAVA_1_6 = getJavaVersionMatches("1.6"); |
| 1069 | ||
| 1070 | /** | |
| 1071 | * <p> | |
| 1072 | * Is <code>true</code> if this is Java version 1.7 (also 1.7.x versions). | |
| 1073 | * </p> | |
| 1074 | * | |
| 1075 | * <p> | |
| 1076 | * The field will return <code>false</code> if {@link #JAVA_VERSION} is <code>null</code>. | |
| 1077 | * </p> | |
| 1078 | * | |
| 1079 | * @since 2.5 | |
| 1080 | */ | |
| 1081 | 0 | public static final boolean IS_JAVA_1_7 = getJavaVersionMatches("1.7"); |
| 1082 | ||
| 1083 | // Operating system checks | |
| 1084 | // ----------------------------------------------------------------------- | |
| 1085 | // These MUST be declared after those above as they depend on the | |
| 1086 | // values being set up | |
| 1087 | // OS names from http://www.vamphq.com/os.html | |
| 1088 | // Selected ones included - please advise dev@commons.apache.org | |
| 1089 | // if you want another added or a mistake corrected | |
| 1090 | ||
| 1091 | /** | |
| 1092 | * <p> | |
| 1093 | * Is <code>true</code> if this is AIX. | |
| 1094 | * </p> | |
| 1095 | * | |
| 1096 | * <p> | |
| 1097 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1098 | * </p> | |
| 1099 | * | |
| 1100 | * @since 2.0 | |
| 1101 | */ | |
| 1102 | 0 | public static final boolean IS_OS_AIX = getOSMatches("AIX"); |
| 1103 | ||
| 1104 | /** | |
| 1105 | * <p> | |
| 1106 | * Is <code>true</code> if this is HP-UX. | |
| 1107 | * </p> | |
| 1108 | * | |
| 1109 | * <p> | |
| 1110 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1111 | * </p> | |
| 1112 | * | |
| 1113 | * @since 2.0 | |
| 1114 | */ | |
| 1115 | 0 | public static final boolean IS_OS_HP_UX = getOSMatches("HP-UX"); |
| 1116 | ||
| 1117 | /** | |
| 1118 | * <p> | |
| 1119 | * Is <code>true</code> if this is Irix. | |
| 1120 | * </p> | |
| 1121 | * | |
| 1122 | * <p> | |
| 1123 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1124 | * </p> | |
| 1125 | * | |
| 1126 | * @since 2.0 | |
| 1127 | */ | |
| 1128 | 0 | public static final boolean IS_OS_IRIX = getOSMatches("Irix"); |
| 1129 | ||
| 1130 | /** | |
| 1131 | * <p> | |
| 1132 | * Is <code>true</code> if this is Linux. | |
| 1133 | * </p> | |
| 1134 | * | |
| 1135 | * <p> | |
| 1136 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1137 | * </p> | |
| 1138 | * | |
| 1139 | * @since 2.0 | |
| 1140 | */ | |
| 1141 | 0 | public static final boolean IS_OS_LINUX = getOSMatches("Linux") || getOSMatches("LINUX"); |
| 1142 | ||
| 1143 | /** | |
| 1144 | * <p> | |
| 1145 | * Is <code>true</code> if this is Mac. | |
| 1146 | * </p> | |
| 1147 | * | |
| 1148 | * <p> | |
| 1149 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1150 | * </p> | |
| 1151 | * | |
| 1152 | * @since 2.0 | |
| 1153 | */ | |
| 1154 | 0 | public static final boolean IS_OS_MAC = getOSMatches("Mac"); |
| 1155 | ||
| 1156 | /** | |
| 1157 | * <p> | |
| 1158 | * Is <code>true</code> if this is Mac. | |
| 1159 | * </p> | |
| 1160 | * | |
| 1161 | * <p> | |
| 1162 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1163 | * </p> | |
| 1164 | * | |
| 1165 | * @since 2.0 | |
| 1166 | */ | |
| 1167 | 0 | public static final boolean IS_OS_MAC_OSX = getOSMatches("Mac OS X"); |
| 1168 | ||
| 1169 | /** | |
| 1170 | * <p> | |
| 1171 | * Is <code>true</code> if this is OS/2. | |
| 1172 | * </p> | |
| 1173 | * | |
| 1174 | * <p> | |
| 1175 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1176 | * </p> | |
| 1177 | * | |
| 1178 | * @since 2.0 | |
| 1179 | */ | |
| 1180 | 0 | public static final boolean IS_OS_OS2 = getOSMatches("OS/2"); |
| 1181 | ||
| 1182 | /** | |
| 1183 | * <p> | |
| 1184 | * Is <code>true</code> if this is Solaris. | |
| 1185 | * </p> | |
| 1186 | * | |
| 1187 | * <p> | |
| 1188 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1189 | * </p> | |
| 1190 | * | |
| 1191 | * @since 2.0 | |
| 1192 | */ | |
| 1193 | 0 | public static final boolean IS_OS_SOLARIS = getOSMatches("Solaris"); |
| 1194 | ||
| 1195 | /** | |
| 1196 | * <p> | |
| 1197 | * Is <code>true</code> if this is SunOS. | |
| 1198 | * </p> | |
| 1199 | * | |
| 1200 | * <p> | |
| 1201 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1202 | * </p> | |
| 1203 | * | |
| 1204 | * @since 2.0 | |
| 1205 | */ | |
| 1206 | 0 | public static final boolean IS_OS_SUN_OS = getOSMatches("SunOS"); |
| 1207 | ||
| 1208 | /** | |
| 1209 | * <p> | |
| 1210 | * Is <code>true</code> if this is a POSIX compilant system, as in any of AIX, HP-UX, Irix, Linux, MacOSX, Solaris | |
| 1211 | * or SUN OS. | |
| 1212 | * </p> | |
| 1213 | * | |
| 1214 | * <p> | |
| 1215 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1216 | * </p> | |
| 1217 | * | |
| 1218 | * @since 2.1 | |
| 1219 | */ | |
| 1220 | 0 | public static final boolean IS_OS_UNIX = IS_OS_AIX || IS_OS_HP_UX || IS_OS_IRIX || IS_OS_LINUX || IS_OS_MAC_OSX |
| 1221 | || IS_OS_SOLARIS || IS_OS_SUN_OS; | |
| 1222 | ||
| 1223 | /** | |
| 1224 | * <p> | |
| 1225 | * Is <code>true</code> if this is Windows. | |
| 1226 | * </p> | |
| 1227 | * | |
| 1228 | * <p> | |
| 1229 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1230 | * </p> | |
| 1231 | * | |
| 1232 | * @since 2.0 | |
| 1233 | */ | |
| 1234 | 0 | public static final boolean IS_OS_WINDOWS = getOSMatches(OS_NAME_WINDOWS_PREFIX); |
| 1235 | ||
| 1236 | /** | |
| 1237 | * <p> | |
| 1238 | * Is <code>true</code> if this is Windows 2000. | |
| 1239 | * </p> | |
| 1240 | * | |
| 1241 | * <p> | |
| 1242 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1243 | * </p> | |
| 1244 | * | |
| 1245 | * @since 2.0 | |
| 1246 | */ | |
| 1247 | 0 | public static final boolean IS_OS_WINDOWS_2000 = getOSMatches(OS_NAME_WINDOWS_PREFIX, "5.0"); |
| 1248 | ||
| 1249 | /** | |
| 1250 | * <p> | |
| 1251 | * Is <code>true</code> if this is Windows 95. | |
| 1252 | * </p> | |
| 1253 | * | |
| 1254 | * <p> | |
| 1255 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1256 | * </p> | |
| 1257 | * | |
| 1258 | * @since 2.0 | |
| 1259 | */ | |
| 1260 | 0 | public static final boolean IS_OS_WINDOWS_95 = getOSMatches(OS_NAME_WINDOWS_PREFIX + " 9", "4.0"); |
| 1261 | // JDK 1.2 running on Windows98 returns 'Windows 95', hence the above | |
| 1262 | ||
| 1263 | /** | |
| 1264 | * <p> | |
| 1265 | * Is <code>true</code> if this is Windows 98. | |
| 1266 | * </p> | |
| 1267 | * | |
| 1268 | * <p> | |
| 1269 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1270 | * </p> | |
| 1271 | * | |
| 1272 | * @since 2.0 | |
| 1273 | */ | |
| 1274 | 0 | public static final boolean IS_OS_WINDOWS_98 = getOSMatches(OS_NAME_WINDOWS_PREFIX + " 9", "4.1"); |
| 1275 | // JDK 1.2 running on Windows98 returns 'Windows 95', hence the above | |
| 1276 | ||
| 1277 | /** | |
| 1278 | * <p> | |
| 1279 | * Is <code>true</code> if this is Windows ME. | |
| 1280 | * </p> | |
| 1281 | * | |
| 1282 | * <p> | |
| 1283 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1284 | * </p> | |
| 1285 | * | |
| 1286 | * @since 2.0 | |
| 1287 | */ | |
| 1288 | 0 | public static final boolean IS_OS_WINDOWS_ME = getOSMatches(OS_NAME_WINDOWS_PREFIX, "4.9"); |
| 1289 | // JDK 1.2 running on WindowsME may return 'Windows 95', hence the above | |
| 1290 | ||
| 1291 | /** | |
| 1292 | * <p> | |
| 1293 | * Is <code>true</code> if this is Windows NT. | |
| 1294 | * </p> | |
| 1295 | * | |
| 1296 | * <p> | |
| 1297 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1298 | * </p> | |
| 1299 | * | |
| 1300 | * @since 2.0 | |
| 1301 | */ | |
| 1302 | 0 | public static final boolean IS_OS_WINDOWS_NT = getOSMatches(OS_NAME_WINDOWS_PREFIX + " NT"); |
| 1303 | // Windows 2000 returns 'Windows 2000' but may suffer from same JDK1.2 problem | |
| 1304 | ||
| 1305 | /** | |
| 1306 | * <p> | |
| 1307 | * Is <code>true</code> if this is Windows XP. | |
| 1308 | * </p> | |
| 1309 | * | |
| 1310 | * <p> | |
| 1311 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1312 | * </p> | |
| 1313 | * | |
| 1314 | * @since 2.0 | |
| 1315 | */ | |
| 1316 | 0 | public static final boolean IS_OS_WINDOWS_XP = getOSMatches(OS_NAME_WINDOWS_PREFIX, "5.1"); |
| 1317 | ||
| 1318 | // ----------------------------------------------------------------------- | |
| 1319 | /** | |
| 1320 | * <p> | |
| 1321 | * Is <code>true</code> if this is Windows Vista. | |
| 1322 | * </p> | |
| 1323 | * | |
| 1324 | * <p> | |
| 1325 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1326 | * </p> | |
| 1327 | * | |
| 1328 | * @since 2.4 | |
| 1329 | */ | |
| 1330 | 0 | public static final boolean IS_OS_WINDOWS_VISTA = getOSMatches(OS_NAME_WINDOWS_PREFIX, "6.0"); |
| 1331 | ||
| 1332 | /** | |
| 1333 | * <p> | |
| 1334 | * Is <code>true</code> if this is Windows 7. | |
| 1335 | * </p> | |
| 1336 | * | |
| 1337 | * <p> | |
| 1338 | * The field will return <code>false</code> if <code>OS_NAME</code> is <code>null</code>. | |
| 1339 | * </p> | |
| 1340 | * | |
| 1341 | * @since 2.5 | |
| 1342 | */ | |
| 1343 | 0 | public static final boolean IS_OS_WINDOWS_7 = getOSMatches(OS_NAME_WINDOWS_PREFIX, "6.1"); |
| 1344 | ||
| 1345 | // ----------------------------------------------------------------------- | |
| 1346 | /** | |
| 1347 | * <p> | |
| 1348 | * SystemUtils instances should NOT be constructed in standard programming. Instead, the class should be used as | |
| 1349 | * <code>SystemUtils.FILE_SEPARATOR</code>. | |
| 1350 | * </p> | |
| 1351 | * | |
| 1352 | * <p> | |
| 1353 | * This constructor is public to permit tools that require a JavaBean instance to operate. | |
| 1354 | * </p> | |
| 1355 | */ | |
| 1356 | public SystemUtils() { | |
| 1357 | 0 | super(); |
| 1358 | 0 | } |
| 1359 | ||
| 1360 | // ----------------------------------------------------------------------- | |
| 1361 | /** | |
| 1362 | * <p> | |
| 1363 | * Gets the Java version number as a <code>float</code>. | |
| 1364 | * </p> | |
| 1365 | * | |
| 1366 | * <p> | |
| 1367 | * Example return values: | |
| 1368 | * </p> | |
| 1369 | * <ul> | |
| 1370 | * <li><code>1.2f</code> for JDK 1.2 | |
| 1371 | * <li><code>1.31f</code> for JDK 1.3.1 | |
| 1372 | * </ul> | |
| 1373 | * | |
| 1374 | * @return the version, for example 1.31f for JDK 1.3.1 | |
| 1375 | * @deprecated Use {@link #JAVA_VERSION_FLOAT} instead. Method will be removed in Commons Lang 3.0. | |
| 1376 | */ | |
| 1377 | @Deprecated | |
| 1378 | public static float getJavaVersion() { | |
| 1379 | 0 | return JAVA_VERSION_FLOAT; |
| 1380 | } | |
| 1381 | ||
| 1382 | /** | |
| 1383 | * <p> | |
| 1384 | * Gets the Java version number as a <code>float</code>. | |
| 1385 | * </p> | |
| 1386 | * | |
| 1387 | * <p> | |
| 1388 | * Example return values: | |
| 1389 | * </p> | |
| 1390 | * <ul> | |
| 1391 | * <li><code>1.2f</code> for JDK 1.2 | |
| 1392 | * <li><code>1.31f</code> for JDK 1.3.1 | |
| 1393 | * </ul> | |
| 1394 | * | |
| 1395 | * <p> | |
| 1396 | * Patch releases are not reported. Zero is returned if {@link #JAVA_VERSION_TRIMMED} is <code>null</code>. | |
| 1397 | * </p> | |
| 1398 | * | |
| 1399 | * @return the version, for example 1.31f for JDK 1.3.1 | |
| 1400 | */ | |
| 1401 | private static float getJavaVersionAsFloat() { | |
| 1402 | 0 | if (JAVA_VERSION_TRIMMED == null) { |
| 1403 | 0 | return 0f; |
| 1404 | } | |
| 1405 | 0 | String str = JAVA_VERSION_TRIMMED.substring(0, 3); |
| 1406 | 0 | if (JAVA_VERSION_TRIMMED.length() >= 5) { |
| 1407 | 0 | str = str + JAVA_VERSION_TRIMMED.substring(4, 5); |
| 1408 | } | |
| 1409 | try { | |
| 1410 | 0 | return Float.parseFloat(str); |
| 1411 | 0 | } catch (Exception ex) { |
| 1412 | 0 | return 0; |
| 1413 | } | |
| 1414 | } | |
| 1415 | ||
| 1416 | /** | |
| 1417 | * <p> | |
| 1418 | * Gets the Java version number as an <code>int</code>. | |
| 1419 | * </p> | |
| 1420 | * | |
| 1421 | * <p> | |
| 1422 | * Example return values: | |
| 1423 | * </p> | |
| 1424 | * <ul> | |
| 1425 | * <li><code>120</code> for JDK 1.2 | |
| 1426 | * <li><code>131</code> for JDK 1.3.1 | |
| 1427 | * </ul> | |
| 1428 | * | |
| 1429 | * <p> | |
| 1430 | * Patch releases are not reported. Zero is returned if {@link #JAVA_VERSION_TRIMMED} is <code>null</code>. | |
| 1431 | * </p> | |
| 1432 | * | |
| 1433 | * @return the version, for example 131 for JDK 1.3.1 | |
| 1434 | */ | |
| 1435 | private static int getJavaVersionAsInt() { | |
| 1436 | 0 | if (JAVA_VERSION_TRIMMED == null) { |
| 1437 | 0 | return 0; |
| 1438 | } | |
| 1439 | 0 | String str = JAVA_VERSION_TRIMMED.substring(0, 1); |
| 1440 | 0 | str = str + JAVA_VERSION_TRIMMED.substring(2, 3); |
| 1441 | 0 | if (JAVA_VERSION_TRIMMED.length() >= 5) { |
| 1442 | 0 | str = str + JAVA_VERSION_TRIMMED.substring(4, 5); |
| 1443 | } else { | |
| 1444 | 0 | str = str + "0"; |
| 1445 | } | |
| 1446 | try { | |
| 1447 | 0 | return Integer.parseInt(str); |
| 1448 | 0 | } catch (Exception ex) { |
| 1449 | 0 | return 0; |
| 1450 | } | |
| 1451 | } | |
| 1452 | ||
| 1453 | /** | |
| 1454 | * Trims the text of the java version to start with numbers. | |
| 1455 | * | |
| 1456 | * @return the trimmed java version | |
| 1457 | */ | |
| 1458 | private static String getJavaVersionTrimmed() { | |
| 1459 | 0 | if (JAVA_VERSION != null) { |
| 1460 | 0 | for (int i = 0; i < JAVA_VERSION.length(); i++) { |
| 1461 | 0 | char ch = JAVA_VERSION.charAt(i); |
| 1462 | 0 | if (ch >= '0' && ch <= '9') { |
| 1463 | 0 | return JAVA_VERSION.substring(i); |
| 1464 | } | |
| 1465 | } | |
| 1466 | } | |
| 1467 | 0 | return null; |
| 1468 | } | |
| 1469 | ||
| 1470 | /** | |
| 1471 | * <p> | |
| 1472 | * Decides if the java version matches. | |
| 1473 | * </p> | |
| 1474 | * | |
| 1475 | * @param versionPrefix | |
| 1476 | * the prefix for the java version | |
| 1477 | * @return true if matches, or false if not or can't determine | |
| 1478 | */ | |
| 1479 | private static boolean getJavaVersionMatches(String versionPrefix) { | |
| 1480 | 0 | if (JAVA_VERSION_TRIMMED == null) { |
| 1481 | 0 | return false; |
| 1482 | } | |
| 1483 | 0 | return JAVA_VERSION_TRIMMED.startsWith(versionPrefix); |
| 1484 | } | |
| 1485 | ||
| 1486 | /** | |
| 1487 | * <p> | |
| 1488 | * Decides if the operating system matches. | |
| 1489 | * </p> | |
| 1490 | * | |
| 1491 | * @param osNamePrefix | |
| 1492 | * the prefix for the os name | |
| 1493 | * @return true if matches, or false if not or can't determine | |
| 1494 | */ | |
| 1495 | private static boolean getOSMatches(String osNamePrefix) { | |
| 1496 | 0 | if (OS_NAME == null) { |
| 1497 | 0 | return false; |
| 1498 | } | |
| 1499 | 0 | return OS_NAME.startsWith(osNamePrefix); |
| 1500 | } | |
| 1501 | ||
| 1502 | /** | |
| 1503 | * <p> | |
| 1504 | * Decides if the operating system matches. | |
| 1505 | * </p> | |
| 1506 | * | |
| 1507 | * @param osNamePrefix | |
| 1508 | * the prefix for the os name | |
| 1509 | * @param osVersionPrefix | |
| 1510 | * the prefix for the version | |
| 1511 | * @return true if matches, or false if not or can't determine | |
| 1512 | */ | |
| 1513 | private static boolean getOSMatches(String osNamePrefix, String osVersionPrefix) { | |
| 1514 | 0 | if (OS_NAME == null || OS_VERSION == null) { |
| 1515 | 0 | return false; |
| 1516 | } | |
| 1517 | 0 | return OS_NAME.startsWith(osNamePrefix) && OS_VERSION.startsWith(osVersionPrefix); |
| 1518 | } | |
| 1519 | ||
| 1520 | // ----------------------------------------------------------------------- | |
| 1521 | /** | |
| 1522 | * <p> | |
| 1523 | * Gets a System property, defaulting to <code>null</code> if the property cannot be read. | |
| 1524 | * </p> | |
| 1525 | * | |
| 1526 | * <p> | |
| 1527 | * If a <code>SecurityException</code> is caught, the return value is <code>null</code> and a message is written to | |
| 1528 | * <code>System.err</code>. | |
| 1529 | * </p> | |
| 1530 | * | |
| 1531 | * @param property | |
| 1532 | * the system property name | |
| 1533 | * @return the system property value or <code>null</code> if a security problem occurs | |
| 1534 | */ | |
| 1535 | private static String getSystemProperty(String property) { | |
| 1536 | try { | |
| 1537 | 0 | return System.getProperty(property); |
| 1538 | 0 | } catch (SecurityException ex) { |
| 1539 | // we are not allowed to look at this property | |
| 1540 | 0 | System.err.println("Caught a SecurityException reading the system property '" + property |
| 1541 | + "'; the SystemUtils property value will default to null."); | |
| 1542 | 0 | return null; |
| 1543 | } | |
| 1544 | } | |
| 1545 | ||
| 1546 | /** | |
| 1547 | * <p> | |
| 1548 | * Is the Java version at least the requested version. | |
| 1549 | * </p> | |
| 1550 | * | |
| 1551 | * <p> | |
| 1552 | * Example input: | |
| 1553 | * </p> | |
| 1554 | * <ul> | |
| 1555 | * <li><code>1.2f</code> to test for JDK 1.2</li> | |
| 1556 | * <li><code>1.31f</code> to test for JDK 1.3.1</li> | |
| 1557 | * </ul> | |
| 1558 | * | |
| 1559 | * @param requiredVersion | |
| 1560 | * the required version, for example 1.31f | |
| 1561 | * @return <code>true</code> if the actual version is equal or greater than the required version | |
| 1562 | */ | |
| 1563 | public static boolean isJavaVersionAtLeast(float requiredVersion) { | |
| 1564 | 0 | return JAVA_VERSION_FLOAT >= requiredVersion; |
| 1565 | } | |
| 1566 | ||
| 1567 | /** | |
| 1568 | * <p> | |
| 1569 | * Is the Java version at least the requested version. | |
| 1570 | * </p> | |
| 1571 | * | |
| 1572 | * <p> | |
| 1573 | * Example input: | |
| 1574 | * </p> | |
| 1575 | * <ul> | |
| 1576 | * <li><code>120</code> to test for JDK 1.2 or greater</li> | |
| 1577 | * <li><code>131</code> to test for JDK 1.3.1 or greater</li> | |
| 1578 | * </ul> | |
| 1579 | * | |
| 1580 | * @param requiredVersion | |
| 1581 | * the required version, for example 131 | |
| 1582 | * @return <code>true</code> if the actual version is equal or greater than the required version | |
| 1583 | * @since 2.0 | |
| 1584 | */ | |
| 1585 | public static boolean isJavaVersionAtLeast(int requiredVersion) { | |
| 1586 | 0 | return JAVA_VERSION_INT >= requiredVersion; |
| 1587 | } | |
| 1588 | ||
| 1589 | /** | |
| 1590 | * Returns whether the {@link #JAVA_AWT_HEADLESS} value is <code>true</code>. | |
| 1591 | * | |
| 1592 | * @return <code>true</code> if <code>JAVA_AWT_HEADLESS</code> is <code>"true"</code>, <code>false</code> otherwise. | |
| 1593 | * | |
| 1594 | * @see #JAVA_AWT_HEADLESS | |
| 1595 | * @since 2.1 | |
| 1596 | * @since Java 1.4 | |
| 1597 | */ | |
| 1598 | public static boolean isJavaAwtHeadless() { | |
| 1599 | 0 | return JAVA_AWT_HEADLESS != null ? JAVA_AWT_HEADLESS.equals(Boolean.TRUE.toString()) : false; |
| 1600 | } | |
| 1601 | ||
| 1602 | /** | |
| 1603 | * <p> | |
| 1604 | * Gets the Java home directory as a <code>File</code>. | |
| 1605 | * </p> | |
| 1606 | * | |
| 1607 | * @return a directory | |
| 1608 | * @throws SecurityException | |
| 1609 | * if a security manager exists and its <code>checkPropertyAccess</code> method doesn't allow access to | |
| 1610 | * the specified system property. | |
| 1611 | * @see System#getProperty(String) | |
| 1612 | * @since 2.1 | |
| 1613 | */ | |
| 1614 | public static File getJavaHome() { | |
| 1615 | 0 | return new File(System.getProperty(JAVA_HOME_KEY)); |
| 1616 | } | |
| 1617 | ||
| 1618 | /** | |
| 1619 | * <p> | |
| 1620 | * Gets the Java IO temporary directory as a <code>File</code>. | |
| 1621 | * </p> | |
| 1622 | * | |
| 1623 | * @return a directory | |
| 1624 | * @throws SecurityException | |
| 1625 | * if a security manager exists and its <code>checkPropertyAccess</code> method doesn't allow access to | |
| 1626 | * the specified system property. | |
| 1627 | * @see System#getProperty(String) | |
| 1628 | * @since 2.1 | |
| 1629 | */ | |
| 1630 | public static File getJavaIoTmpDir() { | |
| 1631 | 0 | return new File(System.getProperty(JAVA_IO_TMPDIR_KEY)); |
| 1632 | } | |
| 1633 | ||
| 1634 | /** | |
| 1635 | * <p> | |
| 1636 | * Gets the user directory as a <code>File</code>. | |
| 1637 | * </p> | |
| 1638 | * | |
| 1639 | * @return a directory | |
| 1640 | * @throws SecurityException | |
| 1641 | * if a security manager exists and its <code>checkPropertyAccess</code> method doesn't allow access to | |
| 1642 | * the specified system property. | |
| 1643 | * @see System#getProperty(String) | |
| 1644 | * @since 2.1 | |
| 1645 | */ | |
| 1646 | public static File getUserDir() { | |
| 1647 | 0 | return new File(System.getProperty(USER_DIR_KEY)); |
| 1648 | } | |
| 1649 | ||
| 1650 | /** | |
| 1651 | * <p> | |
| 1652 | * Gets the user home directory as a <code>File</code>. | |
| 1653 | * </p> | |
| 1654 | * | |
| 1655 | * @return a directory | |
| 1656 | * @throws SecurityException | |
| 1657 | * if a security manager exists and its <code>checkPropertyAccess</code> method doesn't allow access to | |
| 1658 | * the specified system property. | |
| 1659 | * @see System#getProperty(String) | |
| 1660 | * @since 2.1 | |
| 1661 | */ | |
| 1662 | public static File getUserHome() { | |
| 1663 | 0 | return new File(System.getProperty(USER_HOME_KEY)); |
| 1664 | } | |
| 1665 | ||
| 1666 | } |