Table of Contents
1. System of Java
1.getProperty()
1. System of Java
1.getProperty()
System.getProperties() can determine the current system properties, and the return value is a Properties;
System.load(String filename) is equivalent to: System.getProperties().load(String filename). Their function is to load the code file with the specified file name from the local file system as a dynamic library.
System.setProperties(Properties propes) sets system properties to Properties parameters;
System.setProperties(String key,String value) is equivalent to System.getProperties().setProperties(String key,String value): Sets the system property indicated by the specified key
Description of key-related values java.version Java runtime environment version java.vendor Java runtime environment vendor java.vendor.url Java vendor URL java.home Java installation directory java.vm.specification.version Java virtual machine specification version java.vm.specification.vendor Java Virtual Machine Specification Vendor java.vm.specification.name Java virtual machine specification name java.vm.version Java virtual machine implementation version java.vm.vendor Java virtual machine implementation vendor java.vm.name Java virtual machine implementation name java.specification.version Java runtime environment specification version java.specification.vendor Java Runtime Environment Specification Vendor java.specification.name Java runtime environment specification name java.class.version Java class format version number java.class.path Java class path java.library.path List of paths searched when loading the library java.io.tmpdir default temporary file path java.compiler The name of the JIT compiler to use java.ext.dirs Path to one or more extension directories os.name The name of the operating system os.arch operating system architecture os.version operating system version file.separator file separator ("/" on UNIX systems) path.separator path separator (":" on UNIX systems) line.separator line separator ("/n" on UNIX systems) user.name User’s account name user.home User's home directory user.dir The current working directory of the user
Java code
public class TestSystemGetSet { static{ System.setProperty("DB", "mysql");//Can be used as a global variable and used anywhere } public static void main(String[] args) { System.out.println(System.getProperty("os.version")); System.out.println(System.getProperty("java.library.path")); System.out.println(System.getProperty("DB")); Properties properties = System.getProperties(); for (Object key : properties.keySet()) { System.out.println("key=" + key + "\t\t\tvalue=" + properties.get(key)); } } }
Output results
10.0 C:\Program Files\Java\jdk1.8.0_202\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C :\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C :\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\\ VIDIA Corporation\PhysX\ Common;C:\Program Files\\ VIDIA Corporation\\ VIDIA NvDLISR;"C:\Program Files\Java\jdk1.8.0_202\bin;C:\Program Files\Java\jdk1 .8.0_202\jre\bin;";C:\Program Files\Go\bin;C:\Program Files\Go\bin;C:\Program Files\PuTTY\ ;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin;C:\Program Files\Microsoft VS Code\bin;C:\Users\Administrator \AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\go\bin;C:\Program Files\JetBrains\GoLand 2023.2\bin;;C:\ Program Files\JetBrains\IntelliJ IDEA 2023.2.3\bin;;. mysql key=java.runtime.name value=Java(TM) SE Runtime Environment key=sun.boot.library.path value=C:\Program Files\Java\jdk1.8.0_202\jre\bin key=java.vm.version value=25.202-b08 key=DB value=mysql key=java.vm.vendor value=Oracle Corporation key=java.vendor.url value=http://java.oracle.com/ key=path.separator value=; key=java.vm.name value=Java HotSpot(TM) 64-Bit Server VM key=file.encoding.pkg value=sun.io key=user.country value=CN key=user.script value= key=sun.java.launcher value=SUN_STANDARD key=sun.os.patch.level value= key=java.vm.specification.name value=Java Virtual Machine Specification key=user.dir value=D:\WorkSpace\EclipseWorkSpace\springboot_aop key=java.runtime.version value=1.8.0_202-b08 key=java.awt.graphicsenv value=sun.awt.Win32GraphicsEnvironment key=java.endorsed.dirs value=C:\Program Files\Java\jdk1.8.0_202\jre\lib\endorsed key=os.arch value=amd64 key=java.io.tmpdir value=C:\Users\ADMINI~1\AppData\Local\Temp\ key=line.separator value= key=java.vm.specification.vendor value=Oracle Corporation key=user.variant value= key=os.name value=Windows 10 key=sun.jnu.encoding value=GBK key=java.library.path value=C:\Program Files\Java\jdk1.8.0_202\bin;C:\Windows\Sun\Java\bin;C:\Windows\ system32;C:\Windows;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\ Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86) \\ VIDIA Corporation\PhysX\Common;C:\Program Files\\ VIDIA Corporation\\ VIDIA NvDLISR;"C:\Program Files\Java\jdk1.8.0_202\bin;C:\ \Program Files\Java\jdk1.8.0_202\jre\bin;";C:\Program Files\Go\bin;C:\Program Files\Go\bin;C: \Program Files\PuTTY\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin;C:\Program Files\Microsoft VS Code\bin ;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\go\bin;C:\Program Files\JetBrains\GoLand 2023.2 \bin;;C:\Program Files\JetBrains\IntelliJ IDEA 2023.2.3\bin;;. key=java.specification.name value=Java Platform API Specification key=java.class.version value=52.0 key=sun.management.compiler value=HotSpot 64-Bit Tiered Compilers key=os.version value=10.0 key=user.home value=C:\Users\Administrator key=user.timezone value= key=java.awt.printerjob value=sun.awt.windows.WPrinterJob key=file.encoding value=UTF-8 key=java.specification.version value=1.8 key=java.class.path value=C:\Program Files\Java\jdk1.8.0_202\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0 _202\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\access-bridge-64.jar;C:\ \Program Files\Java\jdk1.8.0_202\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1. 8.0_202\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\localedata.jar;C:\ \Program Files\Java\jdk1.8.0_202\jre\lib\ext\\ ashorn.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1. 8.0_202\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunpkcs11.jar;C:\ \Program Files\Java\jdk1.8.0_202\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ javaws.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_202\jre\ \lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_202 \jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\management-agent.jar;C:\Program Files\Java \jdk1.8.0_202\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\rt.jar;D:\WorkSpace\EclipseWorkSpace\springboot_aop\target\test-classes;D:\WorkSpace\EclipseWorkSpace \springboot_aop\target\classes;D:\.m2\repo\org\springframework\spring-context\5.1.6.RELEASE\spring-context-5.1.6.RELEASE.jar ;D:\.m2\repo\org\springframework\spring-aop\5.1.6.RELEASE\spring-aop-5.1.6.RELEASE.jar;D:\.m2\ repo\org\springframework\spring-beans\5.1.6.RELEASE\spring-beans-5.1.6.RELEASE.jar;D:\.m2\repo\org\springframework\ spring-core\5.1.6.RELEASE\spring-core-5.1.6.RELEASE.jar;D:\.m2\repo\org\springframework\spring-jcl\5.1.6. RELEASE\spring-jcl-5.1.6.RELEASE.jar;D:\.m2\repo\org\springframework\spring-expression\5.1.6.RELEASE\spring-expression-5.1. 6.RELEASE.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2023.2.3\lib\idea_rt.jar key=user.name value=Administrator key=java.vm.specification.version value=1.8 key=sun.java.command value=com.lwz.TestSystemGetSet key=java.home value=C:\Program Files\Java\jdk1.8.0_202\jre key=sun.arch.data.model value=64 key=user.language value=zh key=java.specification.vendor value=Oracle Corporation key=awt.toolkit value=sun.awt.windows.WToolkit key=java.vm.info value=mixed mode key=java.version value=1.8.0_202 key=java.ext.dirs value=C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext;C:\Windows\Sun\Java\lib\ ext key=sun.boot.class.path value=C:\Program Files\Java\jdk1.8.0_202\jre\lib\resources.jar;C:\Program Files\Java\jdk1 .8.0_202\jre\lib\rt.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\sunrsasign.jar;C:\Program Files\ Java\jdk1.8.0_202\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jce.jar;C:\ Program Files\Java\jdk1.8.0_202\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jfr.jar; C:\Program Files\Java\jdk1.8.0_202\jre\classes key=java.vendor value=Oracle Corporation key=file.separator value=\ key=java.vendor.url.bug value=http://bugreport.sun.com/bugreport/ key=sun.io.unicode.encoding value=UnicodeLittle key=sun.cpu.endian value=little key=sun.desktop value=windows key=sun.cpu.isalist value=amd64
The most important ability of a programmer is: writing high-quality code! !
If there is a way but no technique, the technique can still be sought. If there is a technique but no way, it will stop at technique.
Whether you are young or old, all programmers need to remember: always work hard to learn new technologies, otherwise you will be abandoned by the times!
The knowledge points of the article match the official knowledge files, and you can further learn related knowledge. Java Skill TreeHomepageOverview 138,269 people are learning the system