1

I'v been playing with java applets recently. In the one im writing now I have a static nested class. It works fine in the viewer, but when I compile it I get 2 class files. classname.class and classname$nestedclassname.class. I've never encountered anything like this (started java a week ago) and I don't how I would jar/sign them. Also, how would the html look? This is how I have it now:

<applet width='50' 
        height='50'
        code='ClassName.class'
        archive='ClassName.jar'>
</applet>

How would I add the second class file?

Ilia Choly
  • 18,070
  • 14
  • 92
  • 160

2 Answers2

2

The classes will all exist in your jar file. If you run this command from the command line you should see them:

jar tvf ClassName.jar

The jar signer task will sign all the classes in a jar file, so you don't have to worry about the inner classes.

Your applet tag simply points to the jar file and the initial class to load.

brianegge
  • 29,240
  • 13
  • 74
  • 99
  • lol I'm an idiot. I thought that it actually loaded the class file so I always uploaded it with the jar :p Well, now I know – Ilia Choly Nov 21 '09 at 06:12
2

You jar them the same way you would jar a single class:

jar cvf ClassName.jar *.class

Your <applet> tag won't change at all; nested class would be included in and loaded from the JAR archive.

ChssPly76
  • 99,456
  • 24
  • 206
  • 195