[debutant]programme qui ne fait rien.
Bonjour,
Voici un probleme basique pour trouver l'addresse du DNS sur le PC local.
Le programme compile bien avec javac NetApp1
Lorsque j'effectue java NetApp1 en revanche il ne m'affiche rien hormis :
_
Quel peut etre le probleme ?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
// An application to find out the current address and DNS name
// of the local computer
import java.net.*;
public class NetApp1
{
public static void main(String args[])
{
try // try to do the following
{
InetAddress localaddr = InetAddress.getLocalHost(); // get local address
String hostName = localaddr.getHostName(); // find the dns name
System.out.println ("Local IP Address : " + localaddr);
System.out.println ("Local hostname : " + hostName);
}
catch (UnknownHostException e) // catch the unknown host exception
{
System.err.println ("Can't detect localhost : " + e);
}
}
} |