In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of how to set System.getProperties () in Java, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will have something to gain after reading this Java article on how to set System.getProperties (). Let's take a look.
1. Get String osName = System.getProperties () .getProperty ("os.name"); System.out.println (osName)
Result output: Windows 10
two。 Set System.setProperty ("jdbc.drivers", "xxx")
Only then will the system variable output the jdbc.drivers system variable name.
3. Package com.sd3e.projectmanager.entity.actDemo; import java.util.Properties;/** * @ version v1.0 * @ ProjectName: jeecg-boot-parent * @ ClassName: Main * @ Description () Java system parameter * @ Author: xbx * @ Date: 2021-10-21 13:11 * / public class Main {public static void main (String [] args) {Properties properties = System.getProperties () String osName = System.getProperties (). GetProperty ("os.name"); System.out.println (osName); / / for (Object obj: properties.keySet ()) {/ / System.out.println ("system variable:" + obj + "=" + properties.get (obj) / / System.out.println ("* *") / /} for (String propertyName:properties.stringPropertyNames ()) {System.out.println ("system variable:" + propertyName+ "=" + properties.getProperty (propertyName));} System.out.println ("operating environment version of Java:" + properties.getProperty ("java.version")); System.out.println ("Java runtime environment vendor:" + properties.getProperty ("java.vendor")) System.out.println ("Java vendor URL:" + properties.getProperty ("java.vendor.url")); System.out.println ("installation path of Java:" + properties.getProperty ("java.home")); System.out.println ("virtual machine specification version of Java:" + properties.getProperty ("java.vm.specification.version")) System.out.println ("Virtual Machine Specification supplier for Java:" + properties.getProperty ("java.vm.specification.vendor")); System.out.println ("Virtual Machine Specification name for Java:" + properties.getProperty ("java.vm.specification.name")); System.out.println ("Virtual Machine implementation version of Java:" + properties.getProperty ("java.vm.version")) System.out.println ("Java virtual machine implementation vendor:" + properties.getProperty ("java.vm.vendor")); System.out.println ("Java virtual machine implementation name:" + properties.getProperty ("java.vm.name")); System.out.println ("Java runtime environment specification version:" + properties.getProperty ("java.specification.version")) System.out.println ("Java runtime environment specification vendor:" + properties.getProperty ("java.specification.vender")); System.out.println ("Java runtime environment specification name:" + properties.getProperty ("java.specification.name")); System.out.println ("class format version number of Java:" + properties.getProperty ("java.class.version")) System.out.println ("classpath of Java:" + properties.getProperty ("java.class.path")); System.out.println ("list of paths to search when loading libraries:" + properties.getProperty ("java.library.path"); System.out.println ("default temporary file path:" + properties.getProperty ("java.io.tmpdir")) System.out.println ("path to one or more extension directories:" + properties.getProperty ("java.ext.dirs")); System.out.println ("operating system name:" + properties.getProperty ("os.name")); System.out.println ("operating system Architecture:" + properties.getProperty ("os.arch")) System.out.println ("operating system version:" + properties.getProperty ("os.version")); / / in unix systems it is "/" System.out.println ("file separator:" + properties.getProperty ("file.separator")); / / in unix systems it is ":" System.out.println ("path separator:" + properties.getProperty ("path.separator")). / / in the unix system, it is "/ n" System.out.println ("line separator:" + properties.getProperty ("line.separator")); System.out.println ("user's account name:" + properties.getProperty ("user.name")); System.out.println ("user's home directory:" + properties.getProperty ("user.home")) System.out.println ("user's current working directory:" + properties.getProperty ("user.dir")) }} / * | java.version | Java runtime environment version | |-|-| java.vendor | | Java Runtime Environment Vendor | | java.vendor.url | Java vendor's 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 | version number in Java format | | java.class.path | Java classpath | | java.library.path | list of paths searched when the library is loaded | | java.io.tmpdir | default temporary file path | | java.compiler | name of the JIT compiler to be used | | java.ext.dirs | path of one or more extended directories | | os.name | name of the operating system | | os.arch | | | operating system architecture | | os.version | operating system version | | file.separator | File delimiter ("/" in UNIX system) | | path.separator | path separator (in UNIX system) | ":") | | line.separator | Line delimiter ("/ n" in UNIX system) | | user.name | user's account name | | user.home | user's home directory | | user.dir | | | user's current working directory | difference between * / 4.Systm.getenv () and System.getProperties () |
(1) System.getenv () is used to obtain the system environment variables, and System.getProperties () is to obtain the current system correlation.
Attribute information.
(2) System.getenv (): returns the string Map of the current system environment, which is immutable and the environment variable is system-dependent
Key value pairs, passed from the parent process to the child process. Such as: JAVA_HOME,PATH, etc.
(3) System.getProperties (): get system-related attributes, such as Java version, operating system information, user name, etc.
These properties related to JVM and operating system. Such as: java.version,os.name,user.dir,file.separator, etc.
This is the end of the article on "how to set System.getProperties () in Java". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to set System.getProperties () in Java". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.