There are a couple of Java system properties, among them things like java.home
and path.separator
, user.home
. The spec does not mention any formal promises on the existence of those values.
Especially I am interested in user.home
. Does it always point to some existing path?
I think you can safely assume that all the properties in that list is always available in any recent (Oracle-provided) JVM.
However, a null
check is more defensive, and not expensive in this case.
I've never seen user.home
to be null or be incorrectly specified by default. However, keep in mind that users can override with -Duser.home=...
, so you can't rely on it to point to an existing path.