One of our applications relies on existence of environment variable that is being set by our server installation. After installing the server I can confirm presence of this variable using 'Environment Variables' dialog. However, when client application executes, calls to set command and Java's System.getenv() method omit this variable, all others are present. What's interesting is that this failure to read particular environment variable only happens on Windows 7 64-bit machine, on Windows XP 32-bit this does not happen. The same code on 32-bit machine returns environment variable set by our server installation. I am not sure if difference between Windows 7 and Windows XP plays role here. Does anybody have any suggestions on how to approach this issue?
2 Answers
A couple of things to check
1) what happens when you type echo %VARNAME% it is likely not too far from what Java is doing behind the scenes.
2) Is this a system wide environmental variable or a per user one? It shouldn't make a difference but it might
3) Can you post your code. The below snippit worked fine for me, does this work for you?
String path = System.getenv("PATH");
1 Comment
positron
1) No output is printed and when I execute set command my variable, which is a system variable is not printed. 2) It's a system variable 3) This is the code I am using and both produce same result: p = r.exec("cmd.exe /c set"); //$NON-NLS-1$ Map<String, String> getenv = System.getenv();
getEnvreturns a case sensitive basedmapon all platforms. BTW, what is the outcome ofSystem.getProperties()? Does is contain the env variable you are searching for?