Windows - Setting environment variables

I'm currently in the most unfortunate situation of having to develop under Windows. The program I'm writing depends on two dll files. The first is a library of native functions. This dll acts as a wrapper around a second dll which is the actual C functions that the program is calling.

The problem is that there are several versions of both dll files, and I frequently have to switch between them. To do this I can use a bat file to execute the java application I'm writing, but then I can't debug it except by using a remote debugger. The latter is problematic as the program executes and quits fairly quickly.

-Djava.library.path only affects from where the first dll is loaded. This first dll then makes the second dll load, and where to load this second dll from is determined by the PATH environment variable. I need to be able to set this PATH variable on a per-debug-configuration basis. It would be neat if you had a field in the Run configuration dialog that would let you either execute a bat file before starting the java app, or set environment variables directly for each configuration.

I have tried to set the PATH variable from inside the application, but without success, the Java classloader seems to use the PATH as it was when the jvm started. A second option is to start IDEA with a bat file and set the PATH there, but that just forces me to reload IDEA every time I need to change library, and as I work on multiple projects simultaneously that is not a very good option.

I'm guessing this can't be very hard to add as the IDEA runner seems to execute in what is basically just a subshell.

I would also appreciate ideas for a temporary fix.

3 comments

>The latter is problematic as the program executes and quits fairly quickly

Use suspend=y parameter. Debugge would stall immediately after launch
until debugger connects to it.

--
Maxim Shafirov
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0

I would also appreciate ideas for a temporary fix.


Version the dll names and pass a parameter to the first ddl so it knows which
second dll to load.


0

Thanks, that is an acceptable workaround, although it means that I still have to use remote debugger and start the program from the command line. It would certainly be much better if I could just start the debug session from inside IntelliJ. In general I would think that the ability to manage the environment variables for the run configurations would be a nice feature.

0

Please sign in to leave a comment.