Intellij idea module default "user.dir"

I am familiar with the idea of ​​intellij. I just import some projects from eclipse , and these are modules in the intellij idea.
I run one main part in one module and get a file can not found exception. I check the user.dir parameter and find it direct for another module (this module is the first module when importing eclipse projects).

 System.out.println(System.getProperty("user.dir")); 

I just want to install user.dir in this module directory when I run the main one in one module. How to install it?

+6
source share
1 answer
  • Create a Run/Debug configuration for your main class (the easiest way is to right-click it and select "Save MyClass.main ()").

  • Now find your configuration (named after your class) in the drop-down list of the main toolbar and select "Edit Configurations"

  • In VM options put -Duser.dir=whatever

Alternatively, installing the Working directory may help you.

+9
source

Source: https://habr.com/ru/post/947723/


All Articles