F
foofolan
Gast
Hallo,
habe ein Applet geschrieben, welches in der eclipse ID funktioniert. Auf dem Webservre bekomme ich die Fehlermeldung "NoSuchElementexception", was habe ich falsch gemacht? hier die Daten:
So habe ich es eingebunden:
<APPLET CODE="IPMACAPPLET.class" WIDTH=500 HEIGHT=200>
<PARAM NAME="ACTION" VALUE="AUTO">
</APPLET>
Applet crashed!
habe ein Applet geschrieben, welches in der eclipse ID funktioniert. Auf dem Webservre bekomme ich die Fehlermeldung "NoSuchElementexception", was habe ich falsch gemacht? hier die Daten:
Java:
import java.applet.Applet;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;
@SuppressWarnings("serial")
public class IPMACAPPLET extends Applet {
Font f1 = new Font( "Helvetica", Font.BOLD, 13 );
Color c1 = new Color( 255, 0, 0 );
Color c2 = new Color( 0, 0, 255 );
String ip="";
String mac="";
public static String getMacAddress() throws SocketException
{
String result = "";
for ( NetworkInterface ni : Collections.list( NetworkInterface.getNetworkInterfaces()) )
{
byte[] hardwareAddress = ni.getHardwareAddress();
if ( hardwareAddress != null )
{
for ( int i = 0; i < hardwareAddress.length; i++ )
result += String.format( (i==0?"":"-")+"%02X", hardwareAddress[i] );
return "MAC ADRESSE: "+result;
}
}
return result;
}
public static String getIPs() throws SocketException{
Enumeration nets;
String ergebnis="";
nets = NetworkInterface.getNetworkInterfaces();
NetworkInterface iface = (NetworkInterface) nets.nextElement();
Enumeration addresses = iface.getInetAddresses();
InetAddress addr = (InetAddress) addresses.nextElement();
InetAddress addr2 = (InetAddress) addresses.nextElement();
String IP_NUMMER = addr2.getHostAddress();
String HOSTNAME = addr2.getCanonicalHostName();
ergebnis="IP: "+IP_NUMMER+" "+"Hostname: "+ HOSTNAME;
return ergebnis;
}
public void init(){
try {
mac=getMacAddress();
ip=getIPs();
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/* @Override */ public void paint( Graphics g )
{
g.setColor( c1 );
g.setFont( f1 );
g.drawString( mac,20,20);
g.setColor( c2 );
g.drawString( ip,20,50);
}
}
So habe ich es eingebunden:
<APPLET CODE="IPMACAPPLET.class" WIDTH=500 HEIGHT=200>
<PARAM NAME="ACTION" VALUE="AUTO">
</APPLET>
Applet crashed!