Friday, January 4, 2013
Today I am going to post how you can display all the system properties with a simple Java program. You will need the java.util.Enumeration and java.util.Properties class. There is a method getProperties() defined in java.lang.System class. This method returns all the properties associated with your system as a Properties reference. Now we get an Enumeration of all keys of the properties. Next we iterate through each element of enumeration and get the value of individual keys and display them.
--------------------------------------------------------------------------------------------------------------------------
import java.util.Enumeration;
import java.util.Properties;
public class SystemProperties{
public static void main (String[] args) {
Properties p=System.getProperties(); //getting system properties
Enumeration keys = p.keys(); //getting all keys of properties
while (keys.hasMoreElements()) {
String key = (String)keys.nextElement(); //getting next key
String value = (String)p.get(key); //getting key value
System.out.println(key + ": " + value);
}
}
}
--------------------------------------------------------------------------------------------------------------------------
java.runtime.name: Java(TM) SE Runtime Environment
sun.boot.library.path: C:\Program Files\Java\jdk1.7.0\jre\bin
java.vm.version: 21.0-b17
java.vm.vendor: Oracle Corporation
java.vendor.url: http://java.oracle.com/
path.separator: ;
java.vm.name: Java HotSpot(TM) Client VM
file.encoding.pkg: sun.io
user.country: US
user.script:
sun.java.launcher: SUN_STANDARD
sun.os.patch.level:
java.vm.specification.name: Java Virtual Machine Specification
user.dir: D:\Choto documents\Choto documents\Java Programs
java.runtime.version: 1.7.0-b147
java.awt.graphicsenv: sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs: C:\Program Files\Java\jdk1.7.0\jre\lib\endorsed
os.arch: x86
java.io.tmpdir: C:\Users\Chelsea\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\jdk1.7.0\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\PC Connectivity Solution\;C:\Program Files\Java\jdk1.7.0\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;.
java.specification.name: Java Platform API Specification
java.class.version: 51.0
sun.management.compiler: HotSpot Client Compiler
os.version: 6.1
user.home: C:\Users\Chelsea
user.timezone:
java.awt.printerjob: sun.awt.windows.WPrinterJob
file.encoding: Cp1252
java.specification.version: 1.7
java.class.path: D:\Java Programs;C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0\lib\dt.jar;C:\Program Files\Java\jdk1.7.0\lib\tools.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\ext\zipfs.jar
user.name: -MadMickael/FFF
java.vm.specification.version: 1.7
sun.java.command: SystemProperties
java.home: C:\Program Files\Java\jdk1.7.0\jre
sun.arch.data.model: 32
user.language: en
java.specification.vendor: Oracle Corporation
awt.toolkit: sun.awt.windows.WToolkit
java.vm.info: mixed mode, sharing
java.version: 1.7.0
java.ext.dirs: C:\Program Files\Java\jdk1.7.0\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
sun.boot.class.path: C:\Program Files\Java\jdk1.7.0\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0\jre\classes
java.vendor: Oracle Corporation
file.separator: \
java.vendor.url.bug: http://bugreport.sun.com/bugreport/
sun.io.unicode.encoding: UnicodeLittle
sun.cpu.endian: little
sun.desktop: windows
sun.cpu.isalist: pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
--------------------------------------------------------------------------------------------------------------------------
DOWNLOAD the source from Mediafire
DOWNLOAD the source from 4shared
--------------------------------------------------------------------------------------------------------------------------
Java Source Code
--------------------------------------------------------------------------------------------------------------------------import java.util.Enumeration;
import java.util.Properties;
public class SystemProperties{
public static void main (String[] args) {
Properties p=System.getProperties(); //getting system properties
Enumeration keys = p.keys(); //getting all keys of properties
while (keys.hasMoreElements()) {
String key = (String)keys.nextElement(); //getting next key
String value = (String)p.get(key); //getting key value
System.out.println(key + ": " + value);
}
}
}
--------------------------------------------------------------------------------------------------------------------------
Output
--------------------------------------------------------------------------------------------------------------------------java.runtime.name: Java(TM) SE Runtime Environment
sun.boot.library.path: C:\Program Files\Java\jdk1.7.0\jre\bin
java.vm.version: 21.0-b17
java.vm.vendor: Oracle Corporation
java.vendor.url: http://java.oracle.com/
path.separator: ;
java.vm.name: Java HotSpot(TM) Client VM
file.encoding.pkg: sun.io
user.country: US
user.script:
sun.java.launcher: SUN_STANDARD
sun.os.patch.level:
java.vm.specification.name: Java Virtual Machine Specification
user.dir: D:\Choto documents\Choto documents\Java Programs
java.runtime.version: 1.7.0-b147
java.awt.graphicsenv: sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs: C:\Program Files\Java\jdk1.7.0\jre\lib\endorsed
os.arch: x86
java.io.tmpdir: C:\Users\Chelsea\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\jdk1.7.0\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\PC Connectivity Solution\;C:\Program Files\Java\jdk1.7.0\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;.
java.specification.name: Java Platform API Specification
java.class.version: 51.0
sun.management.compiler: HotSpot Client Compiler
os.version: 6.1
user.home: C:\Users\Chelsea
user.timezone:
java.awt.printerjob: sun.awt.windows.WPrinterJob
file.encoding: Cp1252
java.specification.version: 1.7
java.class.path: D:\Java Programs;C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0\lib\dt.jar;C:\Program Files\Java\jdk1.7.0\lib\tools.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\ext\zipfs.jar
user.name: -MadMickael/FFF
java.vm.specification.version: 1.7
sun.java.command: SystemProperties
java.home: C:\Program Files\Java\jdk1.7.0\jre
sun.arch.data.model: 32
user.language: en
java.specification.vendor: Oracle Corporation
awt.toolkit: sun.awt.windows.WToolkit
java.vm.info: mixed mode, sharing
java.version: 1.7.0
java.ext.dirs: C:\Program Files\Java\jdk1.7.0\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
sun.boot.class.path: C:\Program Files\Java\jdk1.7.0\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0\jre\classes
java.vendor: Oracle Corporation
file.separator: \
java.vendor.url.bug: http://bugreport.sun.com/bugreport/
sun.io.unicode.encoding: UnicodeLittle
sun.cpu.endian: little
sun.desktop: windows
sun.cpu.isalist: pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
--------------------------------------------------------------------------------------------------------------------------
Download Links
--------------------------------------------------------------------------------------------------------------------------DOWNLOAD the source from Mediafire
DOWNLOAD the source from 4shared
Labels:Utils
Subscribe to:
Post Comments
(Atom)
Total Pageviews
Followers
Labels
- Algorithms (7)
- Annotation (3)
- Files (6)
- Generics (3)
- Graphics2D (5)
- Graphics2D-Images (7)
- Inheritance (2)
- J2EE (9)
- Java 8 (4)
- Java FAQs (19)
- JDBC (3)
- Networking (2)
- Packages (1)
- Reflection (4)
- Security (7)
- Sorting (2)
- Swing (3)
- Threads (3)
- Utils (3)
Popular Posts
-
Today I will show you how you can implement Bankers algorithm in Java. The Banker's algorithm is a resource allocation and deadlock a...
-
------------------------- UPDATE ------------------------- I have updated the code on request of some followers so that they can directly...
-
Today I am going to show how to convert a postfix expression to an infix expression using stack in Java. In an earlier post here we ...
-
Today in this article I will tell you how to convert an infix expression to postfix expression using stack. This is an important applicat...
-
--------------------UPDATE------------------- I have updated my post so that now it can detect IE 11. This modification was necessary as t...
-
Today I am going to show you how you can generate and validate captcha. A CAPTCHA (an acronym for "Completely Automated Public Turin...
-
Today I am going to post a program that will be able to produce all the mColorings of a given graph G. What is mColoring : The problem st...
-
Today in this article I will show you how to create or develop a Tower of Hanoi game in Java. The Tower of Hanoi is a famous problem tha...
I loved reading this piece! Well written! :)
ReplyDeletejason
Student pods