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.

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();

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


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: Logo

You are commenting using your 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