Re: Applets and Inner class problems

From: Alex Hunsley (lard_at_tardis.ed.ac.molar.uk)
Date: 12/12/03


Date: Fri, 12 Dec 2003 17:30:37 +0000

Alex Hunsley wrote:

> Chabonga wrote:
>
>> I feel really dumb right about now. I have adapted an example from
>> sun's site to suit my needs for an image pan and zoom tool. In
>> eclipse, the applet runs fine, given the proper parameters are passed.
>> When I embed the applet in a html page, the JRE console gives me
>> these errors:
>>
>> java.lang.NoClassDefFoundError: imagezoom$DrawingPane
>> at java.lang.Class.getDeclaredConstructors0(Native Method)
>> at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
>> at java.lang.Class.getConstructor0(Unknown Source)
>> .
>> .
>> .
>>
>> The applet tag I am using looks like:
>> <applet code="imagezoom.class" width="300" height="300">
>> <param name="name" value="imagezoom.class">
>> <param name="imagename" value="D0001636.jpg">
>> <param name="path" value="images">
>> Sorry, your browser can't display applets. </applet>
>>
>> I have tried various modifications of this with no luck.
>>
>> DrawingPane is an inner class of imagezoom, the source code of which
>> looks like:
>>
>> Can anyone see what I am doing wrong? TIA,
>>
>> Trev
>
>
> Internal classes get compiled to seperate class file. In this case you
> will end up with a class file called imagezoom$DrawingPane.class as well
> as one called imagezoom.class. Why don't you put all your classes
> (including the inner class file imagezoom$DrawingPane) in a jar, and
> upload that instead. Then you'd reference it as:
>
> <applet code="imagezoom.class" archive="imagezoom.jar" width="300"
> height="300">
>
> Note that in the above I have added an archive parameter for specifying
> your jar!
>
>
> alex

P.S. there's a useful trail at sun about jars and applets:

http://java.sun.com/docs/books/tutorial/post1.0/whatsnew/jar.html



Relevant Pages

  • Re: java script and hosting
    ... I don't know how to use JAR to house the applet. ... Can I simply zip the class file and rename it to ... can you tell me what browser and version you are using? ...
    (comp.lang.java.programmer)
  • Re: Applets and Inner class problems
    ... > eclipse, the applet runs fine, given the proper parameters are passed. ... Internal classes get compiled to seperate class file. ... your jar! ...
    (comp.lang.java.help)
  • Re: Applets and Deep Jar Structure
    ... The html file containing the applet ... and the jar file exist in the same folder. ... What do you want to do with the class file once you find it? ... where this is a class in that package. ...
    (comp.lang.java.help)
  • Re: java script and hosting
    ... The applet is not supposed to be seen. ... My class is not in JAR. ... simply a class file in the same folder as the pages. ... can you tell me what browser and version you are using? ...
    (comp.lang.java.programmer)
  • Re: Applets and custom class loaders
    ... Just put the class file on the server in the ... Since it is not in the Jar ... Class.forNameto load an interface implementation to ... therefore the whole idea of delayed loading a class might not be worse ...
    (comp.lang.java.gui)