1

I'm confused on how to correctly specify a applet's code attribute in a webpage. I have an applet with the absolute path of

~/workspace/myProject/bin/A/B/C/app.class

and my HTML is under myProject. app.class has the package declaration of

package A.B.C

How do I specify that the page should first look in bin and then A,B,C? If I stick the page in /bin, I can use

code = "A/B/C/app.class"

and it works fine, but putting it in myProject and trying

code = "bin/A/B/C/app.class"

doesn't work. I think its because of that package declaration but I don't know how to fix it; i can't change the package declaration. Do I need to use . in someway? I've seen that before and used it in another solution but trying with various combinations of . instead of / doesn't work either. As a side question, could someone explain what the difference between . and / is? This just says its used for delineating file type

Community
  • 1
  • 1
Daniel
  • 2,435
  • 5
  • 26
  • 40

1 Answers1

3

You would use dots instead of the slashes and specify the CODEBASE accordingly

<applet code="A.B.C.app.class" codebase="bin" width="300" height="200">
</applet>
Reimeus
  • 158,255
  • 15
  • 216
  • 276
  • why don't you need to specify that its under /bin? Is that understood? – Daniel Dec 31 '12 at 21:59
  • The `bin` is not part of the package structure. – Reimeus Dec 31 '12 at 22:00
  • ok I get that, but I guess I'm confused about why the webpage cares about the package structure at all. Why does that matter when I have to specify where the .class file is? – Daniel Dec 31 '12 at 22:02
  • The Java plugin loads the applet like any other `JVM` so needs to follow the convention of loading the class in the usual convention i.e. `com.package.foo.MyClass`. – Reimeus Dec 31 '12 at 22:05
  • So does it really matter where I put the HTML? If I put the HTML in `workspace` instead of `myProject`, would this still work? or would I have to add something like `myProject.A.B.C.app.class` – Daniel Dec 31 '12 at 22:11
  • I think you're looking for the codebase attribute, see update. Aside: Applets download as jars, makes them easier to deploy. – Reimeus Dec 31 '12 at 22:16
  • 1
    If the class is `A.B.C.app.class` the code attribute should be `code="A.B.C.app"` – Andrew Thompson Jan 01 '13 at 02:17
  • AFAIK both will work, see [Applet Tag](http://docs.oracle.com/javase/1.4.2/docs/guide/misc/applet.html) – Reimeus Jan 01 '13 at 02:19
  • @Reimeus:with code = "app.class", the plugin first look for file "app.class" on the server, and then "app/class.class" which it doesn't find. – mins Jul 14 '14 at 13:40