Java Code to Display Contents of PATH Variable

Here’s the Java code to display the contents of the PATH variable. The PATH variable is usually set for certain programs and applications, so that you can access those applications from any directory.


import java.io.*;
class Test3{
public static void main(String args[])throws Exception
{
Process p=Runtime.getRuntime().exec("cmd /c echo %path%");
BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line=reader.readLine();
while(line!=null){
System.out.println(line);
line=reader.readLine();
}
}
}

Hope this code will be of use to someone. Have fun. šŸ™‚

Advertisements

About Manikandan Surendren

A PeopleSoft Techno-functional Consultant. An engineering graduate in Computer Science. Technology Enthusiast. Movie freak. Gadget geek.
This entry was posted in Code. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s