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)?
System properties include information about the current user, the current version of the Java runtime, and the character used to separate components of a file path name. Character that separates components of a file path.
The getProperty(String key) method in Java is used to returns the system property denoted by the specified key passed as its argument.It is a method of the java. lang. System Class. where key is the name of the System property.
You can use the usermod command to change the default home directory for a user. What this command does is edit the file /etc/passwd.
In Eclipse, the working directory defaults to the project directory. ( Project->Properties->Run/DebugSettings->Edit->Arguments tab, at the bottom of the page). Edit: Actually, the easiest way to get to it is Run->Open Run Dialog->Arguments tab.
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.
So if you cd
into /somedir
, then run your program, user.dir
will be /somedir
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With