pack200 applet

Trying to understand the relation between the applet tag and the game jar in pack200 games.

Here’s a game that was submitted:

<APPLET CODE="G.class" width="480" HEIGHT="480">
<PARAM NAME="cache_archive" VALUE="drts-4k.jar" />
<PARAM NAME="java_arguments" VALUE="-Djnlp.packEnabled=true" />
</APPLET>

The file that was uploaded for this game is named “drts-4k.jar.pack.gz”. How does the applet know how to retrieve that file? Does it automagically read the cache_archive value, append “.pack.gz”, and look that up from the webserver, ungzip it, and unpack it, and vola it has its jar!?

What happens if the param is:

<PARAM NAME="cache_archive" VALUE="applet.php?gid=999" />

? All go into a mess?

From this link, as I understand it :

  • the client will allways ask for the “*.jar”
  • it is up to the server to give the “*.jar.pack.gz” if the client support it (Accept-Encoding in the HTTP request). Other wise, it have to send the “.jar”
  • the client know if it got “.jar" or ".jar.pack.gz” from the CE (Content-Encoding I think)

So I think it is OK to use a php page to send back the “.jar" or ".jar.pack.gz”

I think you can make the applet tag point directly at a .pack.gz as well.

And isn’t it just “.pack.gz”, not “.jar.pack.gz”? I mean, there’s no jar in there.

java 1.6 can use pack200.gz files directly without server involvement using the code shown in appel’s first post.

since plugin1 does not have the ability to use the server will have to send a pack200 encoding to get it to run on plugin1 and java 1.5

I just copy what is in the link :wink:

[quote]I think you can make the applet tag point directly at a .pack.gz as well
[/quote]
If the apple tag point directly on the .pack.gz, you have to be sure that all explorer that will be use can understant it… I have no idea whish ones are compatible with it. You should make a try and ask us to do the test.

well it would have made much more sense to be able to use it directly, but as we found out yesterday when testing it, it doesn’t.

thx Sun.

seems like only lwjgl applets allow that atm ;D

Damnit, sun.
When I tried a local .html file that pointed at a “M.pack.gz”, a pack200 gz file, it worked. When I uploaded both to my webserver, it no longer worked, despite the file being there.

I can kind of understand why they’d want to enforce backwards compatibility on the server side so it’ll still provide jars for older jvms… but this is really, REALLY overly complicated. And it’s not like code written for 1.5 will run on 1.4 jvms anyway if you use new classes or functions.
* Markus_Persson strangles sun

Is your server providing an accurate Content-Type header? It may be that for local files the browser infers it but for http-provided files it assumes that the server knows what it’s talking about.

The fact that the Java plugin cannot infer (override) some default Content-Type header is bad enough, especially as it got the full file extension in the URL.

Sure, but I was interested more in suggesting workarounds than ranting.

Alright, it’s working. I was just missing the “Content-Encoding: pack200-gzip” header.

‘dont reach the square’ doesnt work for me (Applet G notloaded)

machine:
Apple Powerbook G4
OSX 10.4.11 (fully updated)
Java 1.5.0_19 (fully updated)

Strange, seems to work for me, WinXP:

[quote]Java Plug-in 1.6.0_15
Using JRE version 1.5.0_14-b03 Java HotSpot™ Client VM
[/quote]
Or do I need Java Plug-in 1.5.x despite having JRE 1.5.x?

is there a java-plugin for mac?
testing my version of java for applets gives me java 1.5.0_19
there is no java 1.6 for my machine, but maybe a plugin?

java applets compiled 1.6 will not work on any apple powerpc
nor will they work for most leopard systems
only snow-leopard can handle 1.6 applets

compiling with javac option -source 1.5 would help,
but dont know if pack200 will work with 1.5?

Hm… I have JDK 1.5.14 installed, how can I run the Applets with the 1.5.x browser plug-in? It seems to be gone from Firefox’s Plugins list. I need to download and reinstall the 1.5 jdk?

maybe with appletviewer of jdk1.5?

-target 1.5, however, will help.

I’ve written a new obfustificate / pack / zip chain which is getting the same sort of file size that Riven presented earlier. However I can’t get the browser (using file open on the html file) to get the pack.gz in preference to the .jar using the jre1.6 only parameter tag. (I am using 1.6). If I remove the jar and just leave the pack.gz I get a nice class not found stacktrace. Can this be tested without recourse to a webserver?

My web hosting has .htaccess and php but no servlets. I need to check whether they’re using Apache, as I’ve seen some examples on how to get the right files served up using that. Alternatively I’ll need to hack out some PHP. Anyone got a non-servlet solution working yet?

Does this work for anyone locally? I’m finding that if I have

<applet width="640" height="480" code="a.class">
<param name="cache_archive" value="grav4k_1v3.jar" />
</applet>

it loads from the jar fine, but if I have

<applet width="640" height="480" code="a.class">
<param name="cache_archive" value="grav4k_1v3.jar" />
<param name="java_arguments" value="-Djnlp.packEnabled=true" />
</applet>

I get error messages

java.lang.ClassNotFoundException: a.class
	at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:152)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
	at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:445)
	at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:2880)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1397)
	at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.FileNotFoundException: /tmp/pack200/a/class.class (No such file or directory)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(FileInputStream.java:106)
	at java.io.FileInputStream.<init>(FileInputStream.java:66)
	at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
	at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
	at sun.plugin2.applet.Applet2ClassLoader.getBytes(Applet2ClassLoader.java:469)
	at sun.plugin2.applet.Applet2ClassLoader.access$000(Applet2ClassLoader.java:46)
	at sun.plugin2.applet.Applet2ClassLoader$1.run(Applet2ClassLoader.java:126)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:123)
	... 6 more

I am boggled at -Djnlp.packEnabled=true causing it to interpret the 's code attribute as a fully qualified name rather than the name of a class file. Replacing it with code=“a” doesn’t help: it looks for a file /tmp/pack200/a.class and ignores /tmp/pack200/grav4k_1v3.pack.gz

(Java 1.6.0_15 64-bit on Linux; errors obtained equally via plugin in Firefox and via appletviewer).