• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Calling applet method in JAR file from Javascript

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to call an applet method that resides inside a jar file from Javascript. I am testing this in Firefox, which runs the Embed tag below. If I put my function in the class that runs initially (upload.class) then I can access the function just fine with something like document.uploadAppletFF.myFunction(), but if I put the function in a helper class contained in the jar, I get a function not found error and document.uploadAppletFF.myFunction() no longer works. Do I need some sort of special compilation flag when I create the jar or something? I don't understand why it cant find that function in the helper class. The applet itself runs fine and has no problems using the other classes and methods.

This page (http://java.sun.com/javase/6/docs/technotes/guides/jar/jarGuide.html) leads me to believe that I should have access to the public "helper" class methods as well. "Note that the familiar CODE=myApplet.class parameter must still be present. The CODE parameter, as always, identifies the name of the applet where execution begins. However, the class file for the applet and all of its helper classes are loaded from the JAR file. "



Any ideas would be greatly appreciated.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

For starters, I'd use just the APPLET tag these days, not EMBED or OBJECT. That has no bearing on the problem at hand, though.

The fact that the applet is delivered as a jar file also has no bearing on this.

The thing is, document.uploadAppletFF is a reference to the class that extends (J)Applet, and that's all you get. If you want to call methods in other classes, then you need to channel the call through a method the Applet subclass - you can't call other classes directly, since you don't have a reference to them.
 
T Almo
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, I see. I didn't realize you only got a reference to the class that extended Applet; thought the jar changed that.

Since my main class instantiates a Thread, which then instantiates another class, I just saved that instantiation to a variable, so that I could reference the other classes (e.g. theThread.theclass.getFunction() ) This works, but when I try to access a variable while my applet is uploading (using the write() function), it seems to block my function call from Javascript. Thats probably a threading issue though.

Thank you.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
T Almo, Could you please give a detailed solution.
I have the same problem.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Timo

i need to start a .jar file from HTML/JavaScript on click of a button ..
can you please tell me how can i do it.....

Regards
Sameer
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic