executing shell built-ins using java

I ran into the problem of wanting to execute the dir command. I tried searching for dir.exe in the Windows folder, but I didn’t get any results back. After googling a bit, I found a solution, you have to run cmd.exe and execute from there. Here’s some sample code :

Process child		= Runtime.getRuntime().exec("cmd.exe /c dir");

After you’ve done this, you can do whatever you like with the Process object.


0 Responses to “executing shell built-ins using java”

  1. Leave a Comment

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

Blog Stats

  • 234,395 hits

%d bloggers like this: