2

Is it possible to run a java application from the command line and specifying a working directory for it?

I tried using the -Duser.dir argument like this:

java -Duser.dir=<some directory> -jar <some jar>  

but it didn't help...

Idov
  • 5,006
  • 17
  • 69
  • 106
  • I think this is a duplicate of https://stackoverflow.com/a/840229/281460. As Michael Myers suggests in that post, I don't think there is a reliable way to do this. – jwir3 Jul 04 '18 at 16:40

1 Answers1

1

Just add a path of your app to the classpath and run the app:

java -classpath <path to your app> <your app file name>
Anatolii
  • 14,139
  • 4
  • 35
  • 65