Can I pass the idea project dir in the VM Options for a run configuration? Follow
I want to pass my idea project directory as a VM parameter in a run configuration. I hoped there was something like the property macros in the ant runner configurations, but they don't work, and I don't see any reference to this in the IDEA help file.
Please sign in to leave a comment.
I have found that IJ sets or the VM sets the user.dir System parameter to the module that is being run for JUnit tests, and I would assume that it does the same for applications.
This is set by the 'Use Class path of the JDK module' setting.
The one caviet is that IJ (7,8,9) sometimes will override this setting, if it finds several classes in the Project with identical package and class names. This is because two modules in the project share an identical package and class structure.
I have filed http://www.jetbrains.net/tracker/issue/IDEADEV-35664 and it was never really fixed, even though it was closed as fixed. Fortunately, eclipse doesn't get confused in these situations !
I should also mention that you can also determine were the classes live by using:
URL codeBase = aClass.getProtectionDomain().getCodeSource().getLocation();
Actually, the value of the user.dir system property is set in the Run Configuration dialog via the "Working Directory" text field. Not the Use Classpath setting. It defaults to whatever you have set it to in the default setting for that run configuration type, which, if you have not changed it, is typically the module's root directory.