Configuring Systems environment with Java to invoke JNI calls
I have written some JNI code that works just fine. I call an API out of Java which needs some environment variables set. Currently, I am working on Windows XP SP3.
I need to set a variable (Example: FOO=bar) in the user space and need to add some paths to 开发者_高级运维the systems path. I need to that because I use third party DLLs in my C code which need these environment settings.
Now I am a bit stuck and don't know how to set these variables. I tried a batch file starting the Java programm, but that didn't work because I only changes the environment for that process. JNI seems to get its own process and there for not the settings I just changed.
So, does any of you have an idea how I could handle that?
Thanks for the help and regards from Germany
Marco
JNI does not get its own process - you're doing something wrong in the batch file.
You can set the environment in C code though, using the SetEnvironmentVariable
API call.
What sort of batch script are you using? Normally, variables set in a process propagate down to all processes created from that process: if I do
set toto=abc
in a console window, I find this environment variable in all programs started from that window.
精彩评论