Archiv für die Kategorie: “Java-Snippets”

Java Snippets

Letztens musste ich herausfinden auf welchem Betriebssystem mein Programm ausgeführt wird. Gelöst habe ich es durch Auslesen von System.getProperties().

Eine komplette Übersicht aller Variablen auf die durch diese Methode zugegriffen werden können erhaltet ihr über diesen Code.


Properties sysProperties = System.getProperties();
sysProperties.list(System.out);

// Auslesen eines einzelnen Wertes
System.out.println("Betriebssystem" + sysProperties.get("os.name"));

Auf einem Mac- System erscheint folgende Ausgabe:

– listing properties –
java.runtime.name=Java(TM) 2 Runtime Environment, Stand…
sun.boot.library.path=/System/Library/Frameworks/JavaVM.fra…
java.vm.version=1.5.0_16-133
awt.nativeDoubleBuffering=true
gopherProxySet=false
java.vm.vendor=Apple Inc.
java.vendor.url=http://www.apple.com/
path.separator=:
java.vm.name=Java HotSpot(TM) Client VM
file.encoding.pkg=sun.io
user.country=DE
sun.java.launcher=SUN_STANDARD
sun.os.patch.level=unknown
java.vm.specification.name=Java Virtual Machine Specification
user.dir=/Users/tobbe/Documents/Geschaeft/Prod…
java.runtime.version=1.5.0_16-b06-284
java.awt.graphicsenv=apple.awt.CGraphicsEnvironment
java.endorsed.dirs=/System/Library/Frameworks/JavaVM.fra…
os.arch=i386
java.io.tmpdir=/tmp
line.separator=

java.vm.specification.vendor=Sun Microsystems Inc.
os.name=Mac OS X
sun.jnu.encoding=MacRoman
java.library.path=.:/Library/Java/Extensions:/System/Li…
java.specification.name=Java Platform API Specification
java.class.version=49.0
sun.management.compiler=HotSpot Client Compiler
os.version=10.5.5
http.nonProxyHosts=local|*.local|169.254/16|*.169.254/16
user.home=/Users/xxx
user.timezone=
java.awt.printerjob=apple.awt.CPrinterJob
file.encoding=MacRoman
java.specification.version=1.5
user.name=xxx
java.class.path=/Users/xxx/xxx/xxx/Prod…
java.vm.specification.version=1.0
sun.arch.data.model=32
java.home=/System/Library/Frameworks/JavaVM.fra…
java.specification.vendor=Sun Microsystems Inc.
user.language=de
awt.toolkit=apple.awt.CToolkit
java.vm.info=mixed mode, sharing
java.version=1.5.0_16
java.ext.dirs=/Library/Java/Extensions:/System/Libr…
sun.boot.class.path=/System/Library/Frameworks/JavaVM.fra…
java.vendor=Apple Inc.
file.separator=/
java.vendor.url.bug=http://bugreport.apple.com/
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeLittle
mrj.version=1050.1.5.0_16-284
socksNonProxyHosts=local|*.local|169.254/16|*.169.254/16
ftp.nonProxyHosts=local|*.local|169.254/16|*.169.254/16
sun.cpu.isalist=

Betriebssystem Mac OS X

Popularity: 39% [?]

Comments Keine Kommentare »