File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Process type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Process type" Watch "Process type" New topic

Process type

Shaik Muhammad
Ranch Hand

Joined: Jul 16, 2008
Posts: 36
I am trying to execute 'ping' command in my linux machine through a java program. I am using the following method to execute the command.

The problem is that the options for the ping command are different for windows and linux.
How can i find the type of the process that is started by the exec(command) method(ie. like UNIXProcess or Win32 process)?
What are the types of processes java uses?(ie. like windows process or linux process or mac process).
How can i get their type?
Please Help
Christian Zillmann

Joined: Jun 24, 2009
Posts: 2
Why don't you check for the OS the code is running on and execute the ping command depending on the OS ?
Shaik Muhammad
Ranch Hand

Joined: Jul 16, 2008
Posts: 36
Thank you..
I tried getting os name from runtime instance. It cannot be retrieved by runtime instance. So i used

Why runtime instance is not giving os name?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Shaik Muhammad wrote:
Why runtime instance is not giving os name?

Do you mean "Why didn't they add a method to the Runtime class to tell you the name of the OS?"

Any one of us, I'm sure, can think of hundreds of methods that they might have added to the Java APIs; if all those thousands of methods were added, it would be too bloated to be useable. So although it might make sense for there to be such a method, as you can see, you can still get the information you need without it.

[Jess in Action][AskingGoodQuestions]
Shaik Muhammad
Ranch Hand

Joined: Jul 16, 2008
Posts: 36
Thanks for the reply...
You mean to say that it is to reduce redundancy?
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46405
Have you tried the System.getProperties method, then iterating through the Properties returned?
I agree. Here's the link:
subject: Process type
jQuery in Action, 3rd edition