user.dir 是何方神圣。

news/2024/11/17 3:29:54/

user.dir 是何方神圣。


据说 System.getProperty("user.dir"); 可以获取我们计算机的系统信息。

那么 user.dir 的参数又该怎么传,ta 又可以获得哪些信息?

话不多说,追溯原因。好在文档注释写的非常详细。

    /*** Determines the current system properties.* <p>* First, if there is a security manager, its* <code>checkPropertiesAccess</code> method is called with no* arguments. This may result in a security exception.* <p>* The current set of system properties for use by the* {@link #getProperty(String)} method is returned as a* <code>Properties</code> object. If there is no current set of* system properties, a set of system properties is first created and* initialized. This set of system properties always includes values* for the following keys:* <table summary="Shows property keys and associated values">* <tr><th>Key</th>*     <th>Description of Associated Value</th></tr>* <tr><td><code>java.version</code></td>*     <td>Java Runtime Environment version</td></tr>* <tr><td><code>java.vendor</code></td>*     <td>Java Runtime Environment vendor</td></tr>* <tr><td><code>java.vendor.url</code></td>*     <td>Java vendor URL</td></tr>* <tr><td><code>java.home</code></td>*     <td>Java installation directory</td></tr>* <tr><td><code>java.vm.specification.version</code></td>*     <td>Java Virtual Machine specification version</td></tr>* <tr><td><code>java.vm.specification.vendor</code></td>*     <td>Java Virtual Machine specification vendor</td></tr>* <tr><td><code>java.vm.specification.name</code></td>*     <td>Java Virtual Machine specification name</td></tr>* <tr><td><code>java.vm.version</code></td>*     <td>Java Virtual Machine implementation version</td></tr>* <tr><td><code>java.vm.vendor</code></td>*     <td>Java Virtual Machine implementation vendor</td></tr>* <tr><td><code>java.vm.name</code></td>*     <td>Java Virtual Machine implementation name</td></tr>* <tr><td><code>java.specification.version</code></td>*     <td>Java Runtime Environment specification  version</td></tr>* <tr><td><code>java.specification.vendor</code></td>*     <td>Java Runtime Environment specification  vendor</td></tr>* <tr><td><code>java.specification.name</code></td>*     <td>Java Runtime Environment specification  name</td></tr>* <tr><td><code>java.class.version</code></td>*     <td>Java class format version number</td></tr>* <tr><td><code>java.class.path</code></td>*     <td>Java class path</td></tr>* <tr><td><code>java.library.path</code></td>*     <td>List of paths to search when loading libraries</td></tr>* <tr><td><code>java.io.tmpdir</code></td>*     <td>Default temp file path</td></tr>* <tr><td><code>java.compiler</code></td>*     <td>Name of JIT compiler to use</td></tr>* <tr><td><code>java.ext.dirs</code></td>*     <td>Path of extension directory or directories*         <b>Deprecated.</b> <i>This property, and the mechanism*            which implements it, may be removed in a future*            release.</i> </td></tr>* <tr><td><code>os.name</code></td>*     <td>Operating system name</td></tr>* <tr><td><code>os.arch</code></td>*     <td>Operating system architecture</td></tr>* <tr><td><code>os.version</code></td>*     <td>Operating system version</td></tr>* <tr><td><code>file.separator</code></td>*     <td>File separator ("/" on UNIX)</td></tr>* <tr><td><code>path.separator</code></td>*     <td>Path separator (":" on UNIX)</td></tr>* <tr><td><code>line.separator</code></td>*     <td>Line separator ("\n" on UNIX)</td></tr>* <tr><td><code>user.name</code></td>*     <td>User's account name</td></tr>* <tr><td><code>user.home</code></td>*     <td>User's home directory</td></tr>* <tr><td><code>user.dir</code></td>*     <td>User's current working directory</td></tr>* </table>* <p>* Multiple paths in a system property value are separated by the path* separator character of the platform.* <p>* Note that even if the security manager does not permit the* <code>getProperties</code> operation, it may choose to permit the* {@link #getProperty(String)} operation.** @return     the system properties* @exception  SecurityException  if a security manager exists and its*             <code>checkPropertiesAccess</code> method doesn't allow access*              to the system properties.* @see        #setProperties* @see        java.lang.SecurityException* @see        java.lang.SecurityManager#checkPropertiesAccess()* @see        java.util.Properties*/public static Properties getProperties() {SecurityManager sm = getSecurityManager();if (sm != null) {sm.checkPropertiesAccess();}return props;}
Title
KeyDescription of Associated Value
java.versionJava Runtime Environment version
java.vendorJava Runtime Environment vendor
java.vendor.urlJava vendor URL
java.homeJava installation directory
java.vm.specification.versionJava Virtual Machine specification version
java.vm.specification.vendorJava Virtual Machine specification vendor
java.vm.specification.nameJava Virtual Machine specification name
java.vm.versionJava Virtual Machine implementation version
java.vm.vendorJava Virtual Machine implementation vendor
java.vm.nameJava Virtual Machine implementation name
java.specification.versionJava Runtime Environment specification version
java.specification.vendorJava Runtime Environment specification vendor
java.specification.nameJava Runtime Environment specification name
java.class.versionJava class format version number
java.class.pathJava class path
java.library.pathList of paths to search when loading libraries
java.io.tmpdirDefault temp file path
java.compilerName of JIT compiler to use
java.ext.dirsPath of extension directory or directories Deprecated. This property, and the mechanism which implements it, may be removed in a future release.
os.nameOperating system name
os.archOperating system architecture
os.versionOperating system version
file.separatorFile separator ("/" on UNIX)
path.separatorPath separator (":" on UNIX)
line.separatorLine separator ("\n" on UNIX)
user.nameUser's account name
user.homeUser's home directory
user.dirUser's current working directory

package com.geek;public class HelloWorld {public static void main(String[] args) {System.out.println(System.getProperty("java.version"));// 	Java Runtime Environment version// 11.0.6System.out.println(System.getProperty("java.vendor"));// 	Java Runtime Environment vendor// JetBrains s.r.oSystem.out.println(System.getProperty("java.vendor.url"));// 	Java vendor URL// https://www.jetbrains.com/System.out.println(System.getProperty("java.home"));// 	Java installation directory// /home/geek/geek/tools_my/idea-IU-193.7288.26/jbrSystem.out.println(System.getProperty("java.vm.specification.version"));// 	Java Virtual Machine specification version// 11System.out.println(System.getProperty("java.vm.specification.vendor"));// 	Java Virtual Machine specification vendor// Oracle CorporationSystem.out.println(System.getProperty("java.vm.specification.name"));// 	Java Virtual Machine specification name// Java Virtual Machine SpecificationSystem.out.println(System.getProperty("java.vm.version"));// 	Java Virtual Machine implementation version// 11.0.6+8-b520.66System.out.println(System.getProperty("java.vm.vendor"));// 	Java Virtual Machine implementation vendor// JetBrains s.r.oSystem.out.println(System.getProperty("java.vm.name"));// 	Java Virtual Machine implementation name// OpenJDK 64-Bit Server VMSystem.out.println(System.getProperty("java.specification.version"));// 	Java Runtime Environment specification version// 11System.out.println(System.getProperty("java.specification.vendor"));// 	Java Runtime Environment specification vendor// Oracle CorporationSystem.out.println(System.getProperty("java.specification.name"));// 	Java Runtime Environment System.out.println();specification name// Java Platform API SpecificationSystem.out.println(System.getProperty("java.class.version"));// 	Java class format version number// 55.0System.out.println(System.getProperty("java.class.path"));// 	Java class path// /root/IdeaProjects/untitled/out/production/HelloWorld:/home/geek/geek/tools_my/idea-IU-193.7288.26/lib/idea_rt.jarSystem.out.println(System.getProperty("java.library.path"));// 	List of paths to search when loading libraries// /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/libSystem.out.println(System.getProperty("java.io.tmpdir"));// 	Default temp file path// /tmpSystem.out.println(System.getProperty("java.compiler"));// 	Name of JIT compiler to use// nullSystem.out.println(System.getProperty("java.ext.dirs"));// 	Path of extension directory or directories Deprecated. This property, and the mechanism which implements it, may be removed in a future release.// nullSystem.out.println(System.getProperty("os.name"));// 	Operating system name// LinuxSystem.out.println(System.getProperty("os.arch"));// 	Operating system architecture// amd64System.out.println(System.getProperty("os.version"));// 	Operating system version// 5.4.0-31-genericSystem.out.println(System.getProperty("file.separator"));// 	File separator ("/" on UNIX)// /System.out.println(System.getProperty("path.separator"));// 	Path separator (":" on UNIX)// :System.out.println(System.getProperty("line.separator"));// 	Line separator ("\n" on UNIX)//System.out.println(System.getProperty("user.name"));// 	User's account name// rootSystem.out.println(System.getProperty("user.home"));// 	User's home directory// /rootSystem.out.println(System.getProperty("user.dir"));// 	User's current working directory// /root/IdeaProjects/untitled}}
package com.geek;public class JavaTest {public static void main(String[] args) {System.out.println(System.getProperty("java.version"));// 	Java Runtime Environment version// 1.8.0_241System.out.println(System.getProperty("java.vendor"));// 	Java Runtime Environment vendor// Oracle CorporationSystem.out.println(System.getProperty("java.vendor.url"));// 	Java vendor URL// http://java.oracle.com/System.out.println(System.getProperty("java.home"));// 	Java installation directory// G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jreSystem.out.println(System.getProperty("java.vm.specification.version"));// 	Java Virtual Machine specification version// 1.8System.out.println(System.getProperty("java.vm.specification.vendor"));// 	Java Virtual Machine specification vendor// Oracle CorporationSystem.out.println(System.getProperty("java.vm.specification.name"));// 	Java Virtual Machine specification name// Java Virtual Machine SpecificationSystem.out.println(System.getProperty("java.vm.version"));// 	Java Virtual Machine implementation version// 25.241-b07System.out.println(System.getProperty("java.vm.vendor"));// 	Java Virtual Machine implementation vendor// Oracle CorporationSystem.out.println(System.getProperty("java.vm.name"));// 	Java Virtual Machine implementation name// Java HotSpot(TM) 64-Bit Server VMSystem.out.println(System.getProperty("java.specification.version"));// 	Java Runtime Environment specification version// 1.8System.out.println(System.getProperty("java.specification.vendor"));// 	Java Runtime Environment specification vendor// Oracle CorporationSystem.out.println(System.getProperty("java.specification.name"));// 	Java Runtime Environment System.out.println();specification name// Java Platform API SpecificationSystem.out.println(System.getProperty("java.class.version"));// 	Java class format version number// 52.0System.out.println(System.getProperty("java.class.path"));// 	Java class path// G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\charsets.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\deploy.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\ext\access-bridge-64.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\ext\cldrdata.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\ext\dnsns.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\ext\jaccess.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\ext\jfxrt.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\ext\localedata.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\ext\nashorn.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\ext\sunec.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\ext\sunjce_provider.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\ext\sunmscapi.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\ext\sunpkcs11.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\ext\zipfs.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\javaws.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\jce.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\jfr.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\jfxswt.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\jsse.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\management-agent.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\plugin.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\resources.jar;G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\jre\lib\rt.jar;G:\lyfGeek\IdeaProjects\mybatis-geek\mybatis-05-multi\target\test-classes;G:\lyfGeek\IdeaProjects\mybatis-geek\mybatis-05-multi\target\classes;G:\lyfGeek\maven_repository\mysql\mysql-connector-java\5.1.47\mysql-connector-java-5.1.47.jar;G:\lyfGeek\maven_repository\org\mybatis\mybatis\3.5.3\mybatis-3.5.3.jar;G:\lyfGeek\maven_repository\junit\junit\4.12\junit-4.12.jar;G:\lyfGeek\maven_repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;G:\lyfGeek\maven_repository\org\projectlombok\lombok\1.18.12\lombok-1.18.12.jar;G:\lyfGeek\Program Files\JetBrains\IntelliJ IDEA 2018.3.6\lib\idea_rt.jar;C:\Users\geek\.IntelliJIdea2018.3\system\captureAgent\debugger-agent.jarSystem.out.println(System.getProperty("java.library.path"));// 	List of paths to search when loading libraries// G:\lyfGeek\ProgramFiles\Java\jdk1.8.0_241\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;F:\Program Files (x86)\Python37-32\Scripts\;F:\Program Files (x86)\Python37-32\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;g:\lyfgeek\ProgramFiles\Git\cmd;C:\Users\geek\AppData\Local\Microsoft\WindowsApps;;g:\lyfGeek\Program Files\JetBrains\IntelliJ IDEA 2018.3.6\bin;;g:\Program Files\JetBrains\PyCharm 2018.3.7\bin;;g:\Program Files\JetBrains\WebStorm 2020.1.1\bin;;.System.out.println(System.getProperty("java.io.tmpdir"));// 	Default temp file path// C:\Users\geek\AppData\Local\Temp\System.out.println(System.getProperty("java.compiler"));// 	Name of JIT compiler to use// nullSystem.out.println(System.getProperty("java.ext.dirs"));// 	Path of extension directory or directories Deprecated. This property, and the mechanism which implements it, may be removed in a future release.//System.out.println(System.getProperty("os.name"));// 	Operating system name// Windows 10System.out.println(System.getProperty("os.arch"));// 	Operating system architecture// amd64System.out.println(System.getProperty("os.version"));// 	Operating system version// 10.0System.out.println(System.getProperty("file.separator"));// 	File separator ("/" on UNIX)// \System.out.println(System.getProperty("path.separator"));// 	Path separator (":" on UNIX)// ;System.out.println(System.getProperty("line.separator"));// 	Line separator ("\n" on UNIX)//System.out.println(System.getProperty("user.name"));// 	User's account name// geekSystem.out.println(System.getProperty("user.home"));// 	User's home directory// C:\Users\geekSystem.out.println(System.getProperty("user.dir"));// 	User's current working directory// G:\lyfGeek\IdeaProjects\mybatis-geek}}
package com.geek;public class JavaTest {public static void main(String[] args) {System.out.println(System.getProperty("java.version"));// 	Java Runtime Environment version// 11.0.6System.out.println(System.getProperty("java.vendor"));// 	Java Runtime Environment vendor// JetBrains s.r.oSystem.out.println(System.getProperty("java.vendor.url"));// 	Java vendor URL// https://www.jetbrains.com/System.out.println(System.getProperty("java.home"));// 	Java installation directory// /home/geek/geek/tools_my/idea-IU-193.7288.26/jbrSystem.out.println(System.getProperty("java.vm.specification.version"));// 	Java Virtual Machine specification version// 11System.out.println(System.getProperty("java.vm.specification.vendor"));// 	Java Virtual Machine specification vendor// Oracle CorporationSystem.out.println(System.getProperty("java.vm.specification.name"));// 	Java Virtual Machine specification name// Java Virtual Machine SpecificationSystem.out.println(System.getProperty("java.vm.version"));// 	Java Virtual Machine implementation version// 11.0.6+8-b520.66System.out.println(System.getProperty("java.vm.vendor"));// 	Java Virtual Machine implementation vendor// JetBrains s.r.oSystem.out.println(System.getProperty("java.vm.name"));// 	Java Virtual Machine implementation name// OpenJDK 64-Bit Server VMSystem.out.println(System.getProperty("java.specification.version"));// 	Java Runtime Environment specification version// 11System.out.println(System.getProperty("java.specification.vendor"));// 	Java Runtime Environment specification vendor// Oracle CorporationSystem.out.println(System.getProperty("java.specification.name"));// 	Java Runtime Environment System.out.println();specification name// Java Platform API SpecificationSystem.out.println(System.getProperty("java.class.version"));// 	Java class format version number// 55.0System.out.println(System.getProperty("java.class.path"));// 	Java class path// /home/geek/IdeaProjects/untitled/out/production/untitled:/home/geek/geek/tools_my/idea-IU-193.7288.26/lib/idea_rt.jarSystem.out.println(System.getProperty("java.library.path"));// 	List of paths to search when loading libraries// /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/libSystem.out.println(System.getProperty("java.io.tmpdir"));// 	Default temp file path// /tmpSystem.out.println(System.getProperty("java.compiler"));// 	Name of JIT compiler to use// nullSystem.out.println(System.getProperty("java.ext.dirs"));// 	Path of extension directory or directories Deprecated. This property, and the mechanism which implements it, may be removed in a future release.// nullSystem.out.println(System.getProperty("os.name"));// 	Operating system name// LinuxSystem.out.println(System.getProperty("os.arch"));// 	Operating system architecture// amd64System.out.println(System.getProperty("os.version"));// 	Operating system version// 5.4.0-31-genericSystem.out.println(System.getProperty("file.separator"));// 	File separator ("/" on UNIX)// /System.out.println(System.getProperty("path.separator"));// 	Path separator (":" on UNIX)// :System.out.println(System.getProperty("line.separator"));// 	Line separator ("\n" on UNIX)//System.out.println(System.getProperty("user.name"));// 	User's account name// geekSystem.out.println(System.getProperty("user.home"));// 	User's home directory// /home/geekSystem.out.println(System.getProperty("user.dir"));// 	User's current working directory// /home/geek/IdeaProjects/untitled}}

http://www.ppmy.cn/news/125940.html

相关文章

python安装docx模块出现Import Error: No module named 'exceptions'的解决方案

文章目录 背景介绍原因分析问题解决 背景介绍 python版本 Python 3.6.8IDE版本 PyCharm 2019.3.3 (Professional Edition) Build #PY-193.6494.30, built on February 6, 2020 Runtime version: 11.0.510-b520.38 amd64 Linux 4.18.0-147.el8.x86_64问题描述 导入docx模块报错…

华为智慧办公新品发布,十余款新品款款惊艳

9月13日&#xff0c;华为智慧办公新品发布会如期而至&#xff0c;正式发布华为MateBook 13s笔记本电脑、华为MateBook 14s笔记本电脑、华为MateStation X一体机、华为PixLab X1打印机、华为MateView GT 27英寸曲面屏显示器以及华为MatePad Pro 12.6英寸套装版等十余款新品。 华…

idea插件开发-环境搭建

工欲善其事&#xff0c;必先利其器。——《论语卫灵公》 ideagradle配置 idea下载地址&#xff1a;官网 gradle下载地址&#xff1a;官网 idea与gradle的配置这里就不做过多的赘述了&#xff0c;需要的同学可以参考一下地址进行配置。 idea&#xff1a;https://blog.csdn.…

27. 查看文件系统信息,blkid,xfs_info,dumpe2fs,blkid,语法详解,用法示例

查看文件系统信息&#xff0c;blkid,xfs_info,dumpe2fs,blkid,语法详解,用法示例 文章目录 blikd语法选项示例 xfs_info语法例子输出解释 dumpe2fs语法选项示范 总结友情链接 blikd 查询文件系统类型信息。用来对文件系统类型、LABEL、UUID等信息进行查询。需要事先安装e2fspr…

IntelliJ IDEA调试时点击停止按钮,程序并没有立即停止

Background 调试一段循环更新数据库的程序时&#xff0c;在更新语句处设置了一个断点&#xff0c;明明在更新了一条数据后停止了Debug&#xff0c;但是数据库里的数据却更新了2条。。 IntelliJ IDEA版本信息&#xff1a; IntelliJ IDEA 2019.3.3 (Ultimate Edition) Build #…

华为原厂预装系统出厂系统全系列恢复镜像安装

文件分享地址https://pan.baidu.com/s/16-CUOXJtiHeIw_h-Vou3lQ?pwd8888 HUAWEI MateBook 13 2020(WRTB) HUAWEI MateBook 13(HN&#xff09; HUAWEI MateBook 13 2021(WRTD) HUAWEI MateBook 13 锐龙版(HNL) HUAWEI MateBook 14(KLV) HUAWEI MateBook 14 2020(KLVC) HUAWEI …

intellij idea 启动报错 java.util.concurrent.CompletionException: java.net.BindException: Address already

welcome to my blog 错误描述: 启动intellij idea时报错 java.util.concurrent.CompletionException: java.net.BindException: Address already in use: bindat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)at java.base…

Intellj IDEA在安装插件后无法打开

Intellj IDEA无法启动工程 Intellj IDEA在安装插件后无法启动工程起因处理经过结果 Intellj IDEA在安装插件后无法启动工程 起因 在换了一台新的笔记本之后&#xff0c;紧跟着也是把所有的环境&#xff0c;以及一些配置重新装了一遍&#xff0c;时隔两三年重新装这些东西&…