0

I'm new to this - I have never tried to put an applet online and I'm a fairly new programmer.

I tried to put an applet onto a webpage; the first applet I tried didn't work (Hosted class on a google site file File Cabinet, didn't work because the FTP was ASCII and for classes that results in a magic number error)

So I found a place that can host my files and so that the FTP was BINARY (Which is required for an applet class to work). I made this change and the applet was fine, working fully in a browser, and I was happy.

So now I'm trying to get an applet that accesses text files (hosted in the same place as the class file) to work, but no matter what I try it can't access them.

From what I've read thus far, it seems like I have to create a signed applet so that I can access other files, but that means I have to make a jar file which I cannot do because this is an applet, no main method.

in short: I have an applet that tries to access other text files and it's not working (error in title)

I may have made a mistake somewhere, and if so - any help would be appreciated.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
SSaaM
  • 108
  • 10
  • You can totally make a jar and applet will work fine. Can you please post stacktrace here? – Umer Hayat Jun 16 '12 at 10:40
  • *"never tried to put an applet online and I'm a fairly new programmer"* That is a recipe for disaster. :( Applets are a lot harder to develop than desktop apps., and harder even than desktop apps. deployed over the net using JWS. – Andrew Thompson Jun 16 '12 at 14:17

1 Answers1

1

From what I've read thus far, it seems like I have to create a signed applet so that I can access other files,...

The problem is that a File created by applet code running on the client can never point to a location on the remote server. File objects just don't work that way.

This resource will need to be accessed by URL instead. To form the URL, use a relative path from the code base or document base (where the HTML is). Note that an applet can 'phone home' to get resources from its own code base or document base—even when sand-boxed.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433