简体   繁体   中英

Applet's .jar is messing up?

I'm trying to put an applet into a Google site (Because Domain hosting costs money). I've got that working, it is in the site. Now, I'm completely new to this, and my question is why doesn't my applet work?

The first thing I tried was uploading all the files to Google drive and accessing them there (My applet accesses multiple text files [ONLY READS, DOESN'T WRITE]) but that gave me a magic number error because FTP was ASCII which makes the class file all stupid, or so I've researched.

Okay, so I got a website that hosts files and it chooses the FTP (it automatically did Binary for my class files and ASCII for my text files) this made it better, but apparently unsigned applets can't access files other than the class file (I think).

So, I made a .jar for my applet using jar cvf [jar name].jar [blah blah blah, class files I need and text files I need]

I uploaded it to my file hosting site, and alas - Magic number error! 2 something something a lot of numbers. at this point, my HTML code looked like this:

<applet
codebase = "[URL for jar file]"
archive = "[jar file].jar"
code = "[class file].class"
width = ###
height = ###>
</applet>

paranoid that the site's FTP client was messing with my jar, I used FileZilla to upload to my server (an I selected the binary transfer type), which still resulted in a magic number error specifically 1347093252, which is the start of a zip file I believe (If it helps, when I click on the link for this file, it does in fact download).

I've probably done something stupid, but I would like to reiterate that I'm completely new at this.

If anyone could help, that would be awesome;

Thing's I already tried: Clearing my java cache and loading the applet (from here on, assume all the thing listed end with "and loading the applet"), clearing it again, closing my browser, clearing my java cache, clearing my cache - closing my browser - clearing my cache, reloading, changing computers, changing internet connections, changing computers and internet connections.

First of all, an unsigned applet can read files off of the server it came from. If you put dome text files in the same folder as your applet, the applet can grab then. I think the method is something like getDocumentBase to get the directory your applet wad loaded from. What you cannot do us access the local file system. Making jar files with the command line is a pain. You might want to use an IDE like netbeans to build your project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM