Aniruddha
Aniruddha

Reputation: 3618

IntelliJ Problem with+get current working directory

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.

Upvotes: 15

Views: 17840

Answers (2)

CrazyCoder
CrazyCoder

Reputation: 401965

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.

Upvotes: 29

Dave Newton
Dave Newton

Reputation: 160191

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

Upvotes: 3

Related Questions