Java user.dir property – what exactly does it mean?

Java user.dir property – what exactly does it mean?

Its the directory where java was run from, where you started the JVM. Does not have to be within the users 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:Usersmyuser.

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

user.dir is the User working directory according to the Java Tutorial, System Properties

Java user.dir property – what exactly does it mean?

Typically this is the directory where your app (java) was started (working dir). Typically because it can be changed, eg when you run an app with Runtime.exec(String[] cmdarray, String[] envp, File dir)

Leave a Reply

Your email address will not be published.