Hi All :
I have used a method "System.getenv();" to get a value of user defined environment variable in jar application. I have made the jar application to run from window service. But when i try to start the service, it is not getting user defined environment variable's value and showing null pointer exception. I have tried with System variable name in "System.getenv("JAVA_HOME");" method, its working fine by getting the respective value. What is the error with User variable in envirinment variables. Should i do anything in the code?
views:
493answers:
3
+1
A:
Windows services run on behalf of the system, not a particular user. I believe you can configure the service to run as a specific user, at which point you may get the relevant environment variable - but it would be a lot better to configure the application with a properties file or something similar.
Jon Skeet
2009-02-11 11:34:37
A:
A windows service gets the user environment of the user the service runs as.
Peter Lawrey
2009-02-11 19:28:46