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]
# 1

determining ip address:

try {

InetAddress addr = InetAddress.getLocalHost();

// Get IP Address

byte[] ipAddr = addr.getAddress();

// Get hostname

String hostname = addr.getHostName();

} catch (UnknownHostException e) {

}

Yannixa at 2007-7-13 0:21:48 > top of Java-index,Java Essentials,Java Programming...
# 2

> 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.

sabre150a at 2007-7-13 0:21:48 > top of Java-index,Java Essentials,Java Programming...
# 3
> determining ip address:> > ...You forgot to mention where you got it: http://www.exampledepot.com/egs/java.net/Local.html
prometheuzza at 2007-7-13 0:21:48 > top of Java-index,Java Essentials,Java Programming...
# 4
> You forgot to mention where you got it:> http://www.exampledepot.com/egs/java.net/Local.htmlactually i got it from: http://www.java-tips.org/java-se-tips/java.net/how-to-determine-the-ip-address-and-hostname-of-the-local-ma-2.html
Yannixa at 2007-7-13 0:21:48 > top of Java-index,Java Essentials,Java Programming...
# 5
Thanks alot for your reply..but now hot can i conver the byte[] ipAddr to a string that contains the ip address in the form 000.000.000.000 ? or how can i get each 000 in an integer ?thanks again,
Raieda at 2007-7-13 0:21:48 > top of Java-index,Java Essentials,Java Programming...
# 6
>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
Raieda at 2007-7-13 0:21:48 > top of Java-index,Java Essentials,Java Programming...
# 7
> but now hot can i conver the byte[] ipAddr to a stringipAddr.toString();
Yannixa at 2007-7-13 0:21:48 > top of Java-index,Java Essentials,Java Programming...
# 8

> >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.

sabre150a at 2007-7-13 0:21:48 > top of Java-index,Java Essentials,Java Programming...
# 9

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.

Raieda at 2007-7-13 0:21:48 > top of Java-index,Java Essentials,Java Programming...