Way to set environment variables when I use IntelliJ run/debug?

I am writing an app that uses an API which must have certain environment
variables set before it is run. Is there a way in IntelliJ so that when I
hit the run and/or debug, it will either set certain environment variables
and/or execute some kind of setenv.bat file before executive the exe? The
problem with setting the environment variables in my windows system path is
that the variables are set per application not per computer.

Any ideas?

Thanks!
-Grant


8 comments
Comment actions Permalink

Try set up enviroment in idea.bat

Thanks

--
Alexey Efimov, Software Engineer
Sputnik Labs,
http://www.spklabs.com
"Grant Gochnauer" <ggochnauer@braunconsult.com> wrote in message
news:bji8te$me2$1@is.intellij.net...

I am writing an app that uses an API which must have certain environment
variables set before it is run. Is there a way in IntelliJ so that when I
hit the run and/or debug, it will either set certain environment variables
and/or execute some kind of setenv.bat file before executive the exe? The
problem with setting the environment variables in my windows system path

is

that the variables are set per application not per computer.

>

Any ideas?

>

Thanks!
-Grant

>
>


0
Comment actions Permalink

Thats a good temp fix..... The only problem is that if I am working on 3
different apps in IntelliJ all with the same environment parameters which
have 3 different values...

--Grant


"Alexey Efimov" <aefimov@spklabs.com> wrote in message
news:bji9kq$vh7$1@is.intellij.net...

Try set up enviroment in idea.bat

>

Thanks

>

--
Alexey Efimov, Software Engineer
Sputnik Labs,
http://www.spklabs.com
"Grant Gochnauer" <ggochnauer@braunconsult.com> wrote in message
news:bji8te$me2$1@is.intellij.net...

I am writing an app that uses an API which must have certain environment
variables set before it is run. Is there a way in IntelliJ so that when

I

hit the run and/or debug, it will either set certain environment

variables

and/or execute some kind of setenv.bat file before executive the exe?

The

problem with setting the environment variables in my windows system path

is

that the variables are set per application not per computer.

>

Any ideas?

>

Thanks!
-Grant

>
>

>
>


0
Comment actions Permalink

It is my headache too. I was going to implement plugin but I didn't find open api for this task yet. And I'm still going to create plugin as soon as open api will be appear.

0
Comment actions Permalink

How about setting -Dvariable=XXX parameters on the run dialog?

0
Comment actions Permalink

It makes no sense for me, because my java code starts perl scripts where I use environment variables and I do not want write any code to convert all possible (because list of variables can be expanded) System.getProperties() to native calls (or cmdline executions) for environment setting.
In any case thank you for your advice.

Pavel

0
Comment actions Permalink

You can use Runtime.getRuntime().exec(“perl.sh”);
Optionally you can create an Ant task and run it before every run/debug session, I believe Intellij supports this out of the box

0
Comment actions Permalink

You can pass a set of environment variables to

All you need to do is define your variables in some property file.

0
Comment actions Permalink

Hi, Peter.
Thank you for your reply.
Yes, but I use native code to start external programs from java to have more control with them... I can support environment settings in program starting interface, but it doesn't seem to be a good way. Generally I have several configurations (environment sets in .bat files), which I'd like to debug from AVRORA. And I do not want to restart Avrora for every configuration. The best way I see is plugin to support environment set per run/debug configuration. But...
Pavel

0

Please sign in to leave a comment.