I have a process I want to start from Java. The problem is that due to a mismatch between the remote desktop client and the process I want to start I need to modify the environment variables. I will not use this in production, but only for running tests. I will also just do this until this bug is fixed in the tool I use.
I do not have root access and I am using Linux RHEL7. Anyone having an idea how I can set this environment variable from Java? I should also add that I run this from an IDE.
The following answer was not very helpful due to the lack of actual examples: Is it possible to set an environment variable at runtime from Java?
and the following example was not able to set the variables in the scope I needed to set them: Java - set environment variable
I tried this,
Process p = Runtime.getRuntime().exec("setenv " + name + " " + value);
But get the following error message,
java.io.IOException: Cannot run program "setenv": error=2, No such file or directory
EDIT: Someone suggested this post,
How do I set environment variables from Java?
Unfortunately I do not find any solutions in there. The process I want to start already have a Java API, which does not work in my environment. What I want is an equivalent to the linux command,
setenv NAME VALUE
for the process which java runs in.