I was doing a program asking the following: Write a Java program to get the value of the environment variable USERNAME.
Si I wrote the following code :
// getting username using System.getProperty in Java String user = System.getProperty("user.name"); System.out.println(user); //print sid
After checking solution of exercise they wrote the following code :
// get the value of the specified environment variable USERNAME System.out.println(System.getenv("USERNAME")); // print null
My question is what is the difference between environment variable and property?