This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 Java 8 in Action this week in the Java 8 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: 24168
    
  30

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: 36563
    
  16
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
 
Similar Threads
How to execute a command from Java in Linux?
Writing java wrapper class
PING program
Open a command prompt using Runtime.getRuntime().exec() and run a jar file
How to connect to Linux using Java code?