I understand getenv has been deprecated. ok How do I get these values? For instance and I'm working on Linux here... setenv MYVAR 123456 Now, if I do a System.out.println("MYVAR"); I get a Null value, what am I doing wrong? I have also tried other variable with the same result. The only values that I can get are pre-defined values(java.version, etc..) Thanks for any help. Bill Norton
You can set the operating system all you want, and Java is not going to know about it. The Properties that java knows how to get are listed in the API under System.getProperties. Try: System.out.print(System.getProperties()); If you want to store more properties that then you have to create new properties in java, and load them yourself. Some applications have a .properties file to do this. At execution they read the .properties file and add those to the ones that java already knows about.
Joined: Mar 12, 2001
Actually julia's solution might be even more helpful...try setting the environment variable MYVAR and then running the application like this java -DMYVAR=$MYVAR (Application name)
Joined: Mar 29, 2001
Thank you for your suggestions and the thread on Sun's page. I have to admit though this is pretty disgusting. I not a Java guru but Sun really seemed to drop the ball on this one. How can you deprecate a function and give no alternative way? Especially something as important as pulling in environment variables!!! If anyone could explain this to me I would be thankful. Bill Norton