Java“user.dir”财产 - 究竟是什么意思? [英] Java "user.dir" property - what exactly does it mean?

查看:248
本文介绍了Java“user.dir”财产 - 究竟是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 user.dir dir作为我的单元测试的基础目录(创建大量文件)。这个属性指向当前工作目录是否正确(例如,通过'cd'命令设置)?

I want to use user.dir dir as a base dir for my unit tests (that creates a lot of files). Is it correct that this property points to the current working directory (e.g. set by the 'cd' command)?

推荐答案

这是运行 java 的目录,在那里启动了JVM。不必在用户的主目录中。它可以是用户有权运行java的任何地方。

It's the directory where java was run from, where you started the JVM. Does not have to be within the user's home directory. It can be anywhere where the user has permission to run java.

所以如果你 cd 进入 / somedir ,那么运行你的程序, user.dir 将是 / somedir

So if you cd into /somedir, then run your program, user.dir will be /somedir.

另一个属性 user.home ,指的是用户目录。如 / Users / myuser / home / myuser C:\ Users \\ \\ myuser

A different property, user.home, refers to the user directory. As in /Users/myuser or /home/myuser or C:\Users\myuser.

参见此处,列出系统属性及其说明。

See here for a list of system properties and their descriptions.

这篇关于Java“user.dir”财产 - 究竟是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆