Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you set the current running directory from the java command line?

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?

like image 586
user538442 Avatar asked Dec 14 '10 18:12

user538442


People also ask

How will you get the current working directory in Java?

In Java, we can use System. getProperty("user. dir") to get the current working directory, the directory from where your program was launched.

How does Java command work?

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.


1 Answers

There is a JVM argument -Duser.dir which can be used to set working directory for JVM.

like image 118
Datta Rooyikar Avatar answered Oct 06 '22 16:10

Datta Rooyikar