Obteniendo las propiedades del sistema


En este post voy a describir un sencillo pero util proceso que nos permite obtener información del sistema operativo donde la JVM esta ejecutándose dentro de nuestras clases Java.

El código de la clase PropertiesBlogPost a continuación:


package blog;

import java.util.Properties;
import java.util.Enumeration;;

public class PropertiesBlogPost {

public static void main(String[] args) {

Properties properties = System.getProperties();
Enumeration propertiesNames = properties.propertyNames();

while(propertiesNames.hasMoreElements()) {
String key = (String)propertiesNames.nextElement();
System.out.println(key + " --> " + properties.getProperty(key));
}

}

}

Entonces luego de ejecutar el método estático main obtenemos algo como:


java.runtime.name --> Java(TM) SE Runtime Environment
sun.boot.library.path --> C:\Program Files\Java\jre1.8.0_144\bin
java.vm.version --> 25.144-b01
user.country.format --> CL
java.vm.vendor --> Oracle Corporation
java.vendor.url --> http://java.oracle.com/
path.separator --> ;
java.vm.name --> Java HotSpot(TM) 64-Bit Server VM
file.encoding.pkg --> sun.io
user.script --> 
user.country --> US
sun.java.launcher --> SUN_STANDARD
sun.os.patch.level --> Service Pack 1
java.vm.specification.name --> Java Virtual Machine Specification
user.dir --> C:\Users\MaximilianoM\dev\blog_max
java.runtime.version --> 1.8.0_144-b01
java.awt.graphicsenv --> sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs --> C:\Program Files\Java\jre1.8.0_144\lib\endorsed
os.arch --> amd64
java.io.tmpdir --> C:\Users\MAXIMI~1\AppData\Local\Temp\
line.separator --> 

java.vm.specification.vendor --> Oracle Corporation
user.variant --> 
os.name --> Windows 7
sun.jnu.encoding --> Cp1252
java.library.path --> C:\Program Files\Java\jre1.8.0_144\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_144/bin/server;C:/Program Files/Java/jre1.8.0_144/bin;C:/Program Files/Java/jre1.8.0_144/lib/amd64;C:\app\client\product\12.2.0\client_1\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files\PuTTY\;C:\Program Files\Java\jdk1.8.0_144\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Users\MaximilianoM\dev\software\apache-maven-3.5.0-bin\apache-maven-3.5.0\bin;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\Program Files\TortoiseSVN\bin;C:\Users\MaximilianoM\AppData\Roaming\npm;C:\Users\MaximilianoM\AppData\Local\GitHubDesktop\bin;C:\Users\MaximilianoM\dev\eclipse-jee-oxygen-R-win32-x86_64\eclipse;;.
java.specification.name --> Java Platform API Specification
java.class.version --> 52.0
sun.management.compiler --> HotSpot 64-Bit Tiered Compilers
os.version --> 6.1
user.home --> C:\Users\MaximilianoM
user.timezone --> 
java.awt.printerjob --> sun.awt.windows.WPrinterJob
file.encoding --> Cp1252
java.specification.version --> 1.8
user.name --> MaximilianoM
java.class.path --> C:\Program Files\Java\jre1.8.0_144\lib\resources.jar;C:\Program Files\Java\jre1.8.0_144\lib\rt.jar;C:\Program Files\Java\jre1.8.0_144\lib\jsse.jar;C:\Program Files\Java\jre1.8.0_144\lib\jce.jar;C:\Program Files\Java\jre1.8.0_144\lib\charsets.jar;C:\Program Files\Java\jre1.8.0_144\lib\jfr.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\cldrdata.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\dnsns.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\jaccess.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\jfxrt.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\localedata.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\nashorn.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\sunec.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\sunmscapi.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jre1.8.0_144\lib\ext\zipfs.jar;C:\Users\MaximilianoM\dev\blog_max\bin
java.vm.specification.version --> 1.8
sun.arch.data.model --> 64
java.home --> C:\Program Files\Java\jre1.8.0_144
sun.java.command --> blog.PropertiesBlogPost
java.specification.vendor --> Oracle Corporation
user.language --> en
user.language.format --> es
awt.toolkit --> sun.awt.windows.WToolkit
java.vm.info --> mixed mode
java.version --> 1.8.0_144
java.ext.dirs --> C:\Program Files\Java\jre1.8.0_144\lib\ext;C:\Windows\Sun\Java\lib\ext
sun.boot.class.path --> C:\Program Files\Java\jre1.8.0_144\lib\resources.jar;C:\Program Files\Java\jre1.8.0_144\lib\rt.jar;C:\Program Files\Java\jre1.8.0_144\lib\sunrsasign.jar;C:\Program Files\Java\jre1.8.0_144\lib\jsse.jar;C:\Program Files\Java\jre1.8.0_144\lib\jce.jar;C:\Program Files\Java\jre1.8.0_144\lib\charsets.jar;C:\Program Files\Java\jre1.8.0_144\lib\jfr.jar;C:\Program Files\Java\jre1.8.0_144\classes
java.vendor --> Oracle Corporation
file.separator --> \
java.vendor.url.bug --> http://bugreport.sun.com/bugreport/
sun.cpu.endian --> little
sun.io.unicode.encoding --> UnicodeLittle
sun.desktop --> windows
sun.cpu.isalist --> amd64

Y así obtenemos información importante de nuestro sistema.

Bienvenidos

Bienvenido(a) a mi blog.

Hola como están?

En esta primera entrada quisiera contar que estoy bastante entusiasmado con la idea de llevar un registro de los temas que voy viendo en el dia a dia, espero poder entregar textos claros y de calidad que sean un aporte al lector y al mismo tiempo una forma de mantener una base de conocimientos.