Java System Properties

Über System.getProperty kann Java bestimme Informationen über das System, auf welchem der aktuelle Java Sourcecode ausgeführt wird, liefern. Zum Anzeigen des Benutzerverzeichnisses würde folgender Code ausreichen:

1
2
String userDirectory = System.getProperty("user.home");
System.out.println(userDirectory);

Die Ausgabe wäre in meinem Fall:

C:\Users\bennyn

Folgende System Properties sind verfügbar:

file.encoding – The character encoding for the default locale
file.encoding.pkg – Package with converters that handle converting between local encodings and Unicode
file.separator – The platform-dependent file separator (e.g., „/“ on UNIX, „\“ for Windows)
java.class.path – The value of the CLASSPATH environment variable
java.class.version – The version of the Java API
java.compiler – The just-in-time compiler to use, if any. The java interpreter provided with the JDK initializes this property from the environment variable JAVA_COMPILER.
java.home – The directory in which Java is installed
java.io.tmpdir – The directory in which java should create temporary files
java.version – The version of the Java interpreter
java.vendor – A vendor-specific string
java.vendor.url – A vendor URL
line.separator – The platform-dependent line separator (e.g., „\n“ on UNIX, „\r\n“ for Windows)
os.name – The name of the operating system
os.arch – The system architecture
os.version – The operating system version
path.separator – The platform-dependent path separator (e.g., „:“ on UNIX, „,“ for Windows)
user.dir – The current working directory when the properties were initialized
user.home – The home directory of the current user
user.language – The two-letter language code of the default locale
user.name – The username of the current user
user.region – The two-letter country code of the default locale
user.timezone – The default time zone

Quelle: http://www.mindspring.com/~mgrand/java-system-properties.htm

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.