IntelliJ Problem with+get current working director

2019-02-08 07:25发布

问题:

Here is my maven project structure

ProjectParent
 -Class1
 -Class2
 -Module1 (another sub directory)
 --Module1Class1
 --Module1Class2

Now when I run Module1Class1 from IntelliJ my current working directory is where ProjectParent directory, but when I run Module1Class1 from eclipse, my current working directoru is ProjectParent/Module1 directory.

Why this is different in intellij & how can I change this, so my current directory is always from where my class started execution like in this example 'Module1Class1' directory.

回答1:

You should edit the template Run/Debug configuration and specify $MODULE_DIR$ variable in the Working directory field.

All the new configurations will inherit this default setting and the variable will be substituted with the directory of the module that you want to run.

There is a feature request to make it the default setting, please vote.



回答2:

You can edit the working directory from within the run configurations dialog.