{"id":990,"date":"2018-09-17T19:05:32","date_gmt":"2018-09-17T10:05:32","guid":{"rendered":"https:\/\/chat-messenger.com\/?p=990"},"modified":"2024-07-04T15:05:01","modified_gmt":"2024-07-04T06:05:01","slug":"system-getproperties-list","status":"publish","type":"post","link":"https:\/\/chat-messenger.com\/en\/blog\/java\/system-getproperties-list","title":{"rendered":"Output Java system properties in an easy-to-read format"},"content":{"rendered":"<h2 class=\"common_title\"><a name=\"0\">Java <strong>system property<\/strong>output in alphabetical order. <strong>System.getProperties()<\/strong><\/a><\/h2>\n<p>\n<strong>Java<\/strong>indicates certainty, emphasis, etc.<strong>system property<\/strong>Here is a sample program that outputs keys and values in alphabetical order for easy viewing.<br>\nOnce stored in the TreeMap, the data is sorted alphabetically before output.\n<\/p>\n<p>Usually the following method is well presented, but it is very difficult to see because the values are broken in the middle and not alphabetically ordered.<\/p>\n<div class=\"point\">\n<strong>Properties props = System.getProperties();<\/strong><br>\n<strong>props.list(System.out);<\/strong>\n<\/div>\n<pre style=\"height:100px;overflow:scroll;\" class=\"console\">-- listing properties -- java.runtime.name=Java(TM) 2 Runtime Environment, Stand... sun.boot.library.path=C:\\develop\\Java\\jdk1.5.0_08\\jre\\bin java.vm.version=1.5.0_08-b03 java.vm.vendor=Sun Microsystems Inc. java.vendor.url=http:\/\/java.sun.com\/ path.separator=; java.vm.name=Java HotSpot(TM) Client VM file.encoding.pkg=sun.io user.country=JP sun.os.patch.level=Service Pack 2 java.vm.specification.name=Java Virtual Machine Specification user.dir=C:\\apps\\0-app java.runtime.version=1.5.0_08-b03 java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment java.endorsed.dirs=C:\\develop\\Java\\jdk1.5.0_08\\jre\\lib\\e... os.arch=x86 java.io.tmpdir=C:\\DOCUME~1\\***\\LOCALS~1\\Temp\\ line.separator= java.vm.specification.vendor=Sun Microsystems Inc. user.variant= os.name=Windows XP sun.jnu.encoding=MS932 java.library.path=C:\\develop\\Java\\jdk1.5.0_08\\bin;.;C:\\... java.specification.name=Java Platform API Specification java.class.version=49.0 sun.management.compiler=HotSpot Client Compiler os.version=5.1 user.home=C:\\Documents and Settings\\**** user.timezone= java.awt.printerjob=sun.awt.windows.WPrinterJob file.encoding=MS932 java.specification.version=1.5 user.name=**** java.class.path=C:\\apps\\0-app\\bin;C:\\apps\\0-app\\jre1.... java.vm.specification.version=1.0 sun.arch.data.model=32 java.home=C:\\develop\\Java\\jdk1.5.0_08\\jre java.specification.vendor=Sun Microsystems Inc. user.language=ja awt.toolkit=sun.awt.windows.WToolkit java.vm.info=mixed mode, sharing java.version=1.5.0_08 java.ext.dirs=C:\\develop\\Java\\jdk1.5.0_08\\jre\\lib\\ext sun.boot.class.path=C:\\develop\\Java\\jdk1.5.0_08\\jre\\lib\\r... java.vendor=Sun Microsystems Inc. file.separator=\\ java.vendor.url.bug=http:\/\/java.sun.com\/cgi-bin\/bugreport... sun.cpu.endian=little sun.io.unicode.encoding=UnicodeLittle sun.desktop=windows sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+m...\n<\/pre>\n<p><script type=\"text\/javascript\" src=\"https:\/\/chat-messenger.com\/js\/common.js?dd12sssas2223\" charset=\"UTF-8\"><\/script><br>\n<script type=\"text\/javascript\"> writePR(); <\/script><\/p>\n<h2 class=\"common_title\"><a name=\"1\">sample program<\/a><\/h2>\n<pre class=\"sample_src\">\/** * Prints system property keys and values in alphabetical order. *\/ public static void outputSystemProperties() { Properties p = System.getProperties(); TreeMap map = new TreeMap(); map.putAll(p); Iterator itr = map.keySet().iterator(); while (itr.hasNext()) { String key = (String)itr.next(); String value = (String)map.get(key); System.out.println(key + &quot;=&quot; + value);\n<\/pre>\n\n<h2 class=\"common_title\"><a name=\"2\">Execution Result<\/a><\/h2>\n<p>\u25c6Example of Execution<\/p>\n<pre class=\"sample_src\">public static void main(String[] args) { outputSystemProperties();\n<\/pre>\n<p>\u25c6Output result<\/p>\n<pre style=\"height:300px;overflow:scroll;overflow-x:scroll;overflow-y:scroll\" class=\"console\">awt.toolkit=sun.awt.windows.WToolkit file.encoding=MS932 file.encoding.pkg=sun.io file.separator=\\ java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment java.awt.printerjob=sun.awt.windows.WPrinterJob java.class.path=C:\\apps\\0-app\\bin;C:\\apps\\0-app\\jre1.6.0\\lib\\rt.jar;C:\\apps\\0-app\\sys\\lib\\bcprov-jdk14-123.jar java.class.version=49.0 java.endorsed.dirs=C:\\develop\\Java\\jdk1.5.0_08\\jre\\lib\\endorsed java.ext.dirs=C:\\develop\\Java\\jdk1.5.0_08\\jre\\lib\\ext java.home=C:\\develop\\Java\\jdk1.5.0_08\\jre java.io.tmpdir=C:\\DOCUME~1\\***\\LOCALS~1\\Temp\\ java.library.path=C:\\develop\\Java\\jdk1.5.0_08\\bin;.;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\develop\\Java\\jdk1.5.0_08\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\ProgramFilesDevelop\\TOOLS\\ant-1.6.1\\bin;C:\\develop\\eclipse32\\extensions\\tptp-4.2.0\\agent-controller\\\\bin;C:\\Program Files\\QuickTime\\QTSystem\\ java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition java.runtime.version=1.5.0_08-b03 java.specification.name=Java Platform API Specification java.specification.vendor=Sun Microsystems Inc. java.specification.version=1.5 java.vendor=Sun Microsystems Inc. java.vendor.url=http:\/\/java.sun.com\/ java.vendor.url.bug=http:\/\/java.sun.com\/cgi-bin\/bugreport.cgi java.version=1.5.0_08 java.vm.info=mixed mode, sharing java.vm.name=Java HotSpot(TM) Client VM java.vm.specification.name=Java Virtual Machine Specification java.vm.specification.vendor=Sun Microsystems Inc. java.vm.specification.version=1.0 java.vm.vendor=Sun Microsystems Inc. java.vm.version=1.5.0_08-b03 line.separator= os.arch=x86 os.name=Windows XP os.version=5.1 path.separator=; sun.arch.data.model=32 sun.boot.class.path=C:\\develop\\Java\\jdk1.5.0_08\\jre\\lib\\rt.jar;C:\\develop\\Java\\jdk1.5.0_08\\jre\\lib\\i18n.jar;C:\\develop\\Java\\jdk1.5.0_08\\jre\\lib\\sunrsasign.jar;C:\\develop\\Java\\jdk1.5.0_08\\jre\\lib\\jsse.jar;C:\\develop\\Java\\jdk1.5.0_08\\jre\\lib\\jce.jar;C:\\develop\\Java\\jdk1.5.0_08\\jre\\lib\\charsets.jar;C:\\develop\\Java\\jdk1.5.0_08\\jre\\classes sun.boot.library.path=C:\\develop\\Java\\jdk1.5.0_08\\jre\\bin sun.cpu.endian=little sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86 sun.desktop=windows sun.io.unicode.encoding=UnicodeLittle sun.jnu.encoding=MS932 sun.management.compiler=HotSpot Client Compiler sun.os.patch.level=Service Pack 2 user.country=JP user.dir=C:\\apps\\0-app user.home=C:\\Documents and Settings\\*** user.language=ja user.name=*** user.timezone= user.variant=\n<\/pre>\n<p>I see that all information is listed in alphabetical order.<br>\nEspecially if all java.class.path, java.library.path, etc. are not shown, it will take a long time to solve the problem.<\/p>\n<div class=\"point\">\njava.class.path=C:\\apps\\0-app\\bin;C:\\apps\\0-app\\jre1....<br>\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u2193arrow (mark or symbol)<br>\njava.class.path=C:\\apps\\0-app\\bin;C:\\apps\\0-app\\jre1.6.0\\lib\\rt.jar;C:\\apps\\0-app\\sys\\lib\\bcprov-jdk14-123.jar\n<\/div>\n\n\n<h2>summary<\/h2>\n\n\n\n<p>This article explains how to organize Java system properties in alphabetical order for easy viewing. With normal property output methods, the information is cut off or displayed out of order, making it difficult to read.<code>TreeMap<\/code>Using this to sort and output the properties makes it easier to understand. A concrete example program is introduced to provide a method for Java programmers to check system properties efficiently.<\/p>\n\n\n\n<p>For those with skills as a Java programmer, side jobs are highly recommended. This is because Java is widely used in the development of corporate mission-critical systems and web applications, and is in high demand. By using Java as a side job, you can not only increase your income, but also improve your skills and learn new technologies.<\/p>\n\n\n<div class=\"swell-block-postLink\">\t\t\t<div class=\"p-blogCard -external\" data-type=\"type3\" data-onclick=\"clickLink\">\n\t\t\t\t<div class=\"p-blogCard__inner\">\n\t\t\t\t\t<span class=\"p-blogCard__caption\">Indieverse Freelance Media\u2026<\/span>\n\t\t\t\t\t<div class=\"p-blogCard__thumb c-postThumb\"><figure class=\"c-postThumb__figure\"><img src=\"https:\/\/freelance.indieverse.co.jp\/media\/wp-content\/uploads\/2020\/08\/wes-hicks-4-EeTnaC1S4-unsplash-scaled.jpg\" alt=\"\" class=\"c-postThumb__img u-obf-cover\" width=\"320\" height=\"180\"><\/figure><\/div>\t\t\t\t\t<div class=\"p-blogCard__body\">\n\t\t\t\t\t\t<a class=\"p-blogCard__title\" href=\"https:\/\/dividable.net\/sidework\/how-to-earn-money-by-programming-sidework\" target=\"_blank\" rel=\"noopener noreferrer\">Steps to making money with a programming side job and 5 side job sites [with example jobs]<\/a>\n\t\t\t\t\t\t<span class=\"p-blogCard__excerpt\">\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u526f\u696d\u3067\u7a3c\u3050\u624b\u9806\u3068\u9078\u3073\u65b9\u3092\u89e3\u8aac\u3002\u30b9\u30ad\u30eb\u68da\u5378\u3057\u304b\u3089\u7a3c\u50cd\u6761\u4ef6\u6574\u7406\u3001\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u6d3b\u7528\u307e\u3067\u3001&#8230;<\/span>\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>Print Java system properties alphabetically System.getProperties() in Java [\u2026]<\/p>","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":""},"categories":[19],"tags":[],"_links":{"self":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts\/990"}],"collection":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/comments?post=990"}],"version-history":[{"count":5,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts\/990\/revisions"}],"predecessor-version":[{"id":11098,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts\/990\/revisions\/11098"}],"wp:attachment":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/media?parent=990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/categories?post=990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/tags?post=990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}