java get environment variable
The getenv() method of the java.lang.System provide us the functionality to get the environment variable value. To get the single environment variables value we have to call the getenv("environment variable") method where environment variable is a value that we want to evaluate. Here is the simple example of getting environment variable "WINDIR".
Here is the full code of GetEnvironmentVariable.java as follows:
GetEnvironmentVariable.java
import java.util.*;
|
Output:
| C:\javaexamples>javac GetEnvironmentVariable.java C:\javaexamples>java GetEnvironmentVariable Environment Variable are =>C:\WINNT |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Java example program to get the environment variable
Post your Comment