I am running a Java application from the command line. Can I specify a command line argument to set the current running directory to something other than where the application is actually going to run?
In Java, we can use System. getProperty("user. dir") to get the current working directory, the directory from where your program was launched.
The java command starts a Java application. It does this by starting a Java runtime environment, loading a specified class, and calling that class's main method. By default, the first argument without an option is the name of the class to be called. A fully qualified class name should be used.
There is a JVM argument -Duser.dir
which can be used to set working directory for JVM.
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