File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Process type" Watch "Process type" New topic
Author

Process type

Shaik Muhammad
Ranch Hand

Joined: Jul 16, 2008
Posts: 36
Hi
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
Greenhorn

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
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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
Sheriff

Joined: Oct 13, 2005
Posts: 39396
    
  28
Have you tried the System.getProperties method, then iterating through the Properties returned?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Process type