Maybe this will work:
Process p = Runtime.Runtime().exec("ipconfig");
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
Here's code for the lazy man. Just change the host name to your computer name, because I'm not doing that for you too. If you use "localhost", it'll just return the local loopback IP.
import java.net.*;
class NetJunk
{
public static void main () throws UnknownHostException
{
String host = "Newton";
InetAddress ia = InetAddress.getByName(host);
System.out.println ("IP Address = " + ia.getHostAddress());
}
}
Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
Gotta love people who want help taking an os independent programming language to make a program that is usable in windows only.
Sauce
Junior Poster in Training
55 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
Sorry mmiikkee i wasn't refering to your code, which looked nice btw, but i was refering to the name of the thread "Put the DOS commands into a java program". And yes piggy backing off shell or dos commands are handy in some situations.
Sauce
Junior Poster in Training
55 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
freesoft_2000
Practically a Master Poster
623 posts since Jun 2004
Reputation Points: 25
Solved Threads: 10
why has noone told him yet that "the DOS command" will never be available from Java for the simple reason that Java doesn't work on DOS based machines?
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337