leaningtech / cheerpj-meta

Run Java 8 applications, libraries, applets, Java Web Start, and Oracle Forms on the web without legacy plugins.
https://labs.leaningtech.com/cheerpj
459 stars 21 forks source link

Can not display different applets with different .jar on the same .htm page #128

Closed mstar46 closed 3 years ago

mstar46 commented 3 years ago

(for sere) Here is a page that should display four applets: a small (S) at the top right, a large (L) in the middle, and two medium (M) at the bottom: http://www.polyhedra-world.nc/stuff/colorsurf_.htm - only S works S and the Ms use live.jar, L uses colosurf.jar (both .jar are compiled into .jar.js)

I then created a test page with a minimum HTML code: http://www.polyhedra-world.nc/stuff/colorsurf-test1.htm - only L works (choose increment 20 and use the arrows) Disturbed by this result, I tried two more test pages: http://www.polyhedra-world.nc/stuff/colorsurf-test2.htm - L does not work http://www.polyhedra-world.nc/stuff/colorsurf-test3.htm - only S works Two other tests verify my suspicions: http://www.polyhedra-world.nc/stuff/colorsurf-testL.htm - L works http://www.polyhedra-world.nc/stuff/colorsurf-testSM.htm - S and the Ms work

It therefore seems that the use of a second .jar disturbs CheerpJ who then refuses to do his job. Is there a solution? or can we only use one .jar per page?

sere commented 3 years ago

Hello mstar46,

It's definitely possible to have different JARs in the same page :) There are several things:

Please move the content of the "live" folder in the current folder as ".." is ignored.

To get the same behaviour in CheerpJ as in native use the option {enablePreciseAppletArchives:true} in cheerpjInit(). The default option is false for backwards compatibility with previous versions of CheerpJ.  Without this, CheerpJ will not be able to load the second jar archive.

By doing this, you'll notice that the error message changes from load: class Live not found to java.lang.SecurityException: class "Live"'s signer information does not match signer information of other classes in the same package. You need to take out the signature from the live.jar (this is true in native too). On Linux you can run zip -d live.jar 'META-INF/*.SF' 'META-INF/*.RSA' (other options here: https://stackoverflow.com/questions/7757083/how-do-i-unsign-a-jar). colorsurf.jar is already unsigned, so no need to modify it.

I tested this in local copying the page http://www.polyhedra-world.nc/stuff/colorsurf_.htm (ignore the background color and fonts, I didn't copy css and style files). image

cheers, sere

mstar46 commented 3 years ago

It works perfectly (I put all the files in a new directory). http://www.polyhedra-world.nc/stuff/colorsurf/colorsurf_.htm Once again thank you very much for your efficient help. CheerpJ gives my site a second life!