I have added one environment variable manually in windows 7 and i am getting null while I am trying to get it from java program.
public static void main(String[] args) {
System.out.println(System.getenv("name"));
}
I am using java 1.7
I have added one environment variable manually in windows 7 and i am getting null while I am trying to get it from java program.
public static void main(String[] args) {
System.out.println(System.getenv("name"));
}
I am using java 1.7
to answer your own question try this :
System.out.println(System.getenv());
then you should be able to see all the set values in environment.
for example if you are trying to get user home, the property you are looking for is :
System.out.println(System.getenv("HOMEPATH"));
you may want to check the properties as well, it could be the case that you added something to the properties
System.out.println(System.getProperties());
also this link might be a use for you: