Applet not working properly ...
Hi all,
I am trying to determine the visitors' IP addresses using a java applet. The only way I can think of is using some php code to determine the IP address then passing it to my applet using the getParameter(String key). However the applet is not working and it's giving me the following error:
java.lang.NoClassDefFoundError: Click$1
at Click.init(Click.java:34)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Any ideas on this error? or on another easier way of determining the ip address ?
regards
[594 byte] By [
Raieda] at [2007-11-27 9:52:43]

determining ip address:
try {
InetAddress addr = InetAddress.getLocalHost();
// Get IP Address
byte[] ipAddr = addr.getAddress();
// Get hostname
String hostname = addr.getHostName();
} catch (UnknownHostException e) {
}
> Hi all,
>
> I am trying to determine the visitors' IP addresses
> using a java applet. The only way I can think of is
> using some php code to determine the IP address then
> passing it to my applet using the getParameter(String
> key). However the applet is not working and it's
> giving me the following error:
>
> java.lang.NoClassDefFoundError: Click$1
> at Click.init(Click.java:34)
> at sun.applet.AppletPanel.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
>
> Any ideas on this error? or on another easier way of
> determining the ip address ?
>
> regards
This exception indicates that you have not made the class file of the first anonymous class within your class Click available to the Applet. It has nothing to do with not being able to find the IP address.
> >This exception indicates that you have not made the
> class file of the first anonymous class within your
> class Click available to the Applet. It has
> > nothing to do with not being able to find the IP
> address.
>
> I only have one class which is Click.class :S
No! You have only one explicit class (Click) but you have at least one anonymous inner class which the compiler gives the class name Click$1 and places in the file Click$1.class. Files Click.class and Click$1.class constitute the code for the Applet and therefore both must be in the directory (or jar) being used to load the Applet from.
Thanks guys for your replies ...
Yannix : i tried to use the toString method but it returned the reference of the byte ( i guess). It returned something like (BD@GH?D).
Also i've uploaded the applet to check if it gives me my ip but it gave me local host !
sabre150 : what do you mean by anonymouse inner class? That is who created that anonymouse class and where can i find it?
regards.