I'd like to use one-jar to package a single jar for an applet.
I'm able to make a jar but I haven't figured out how to reference the correct applet class to start it:
<applet code="org.concord.sensor.applet.OTSensorApplet" archive="/jars/goio-applet.jar">
I used this in the boot-manifest.mf file:
I know that's probably not going to work - because applets don't have a 'main' class.
P. Simon Tuffs
Interesting question. You're right that the applet container won't run the one-jar file to give you what you want, but it may be possible to fake it. The One-JAR Boot class is the key: it's main program does various things, one of which is to instantiate a new JarClassLoader that knows how to load other classes from jars inside the One-JAR. That classloader is then used to load the One-Jar-Main class to start the application. What is needed therefore is a java.applet.Applet bootstrapper that does the same things as com.simontuffs.onejar.Boot. In fact, all it should need to do is to call Boot.run(null).
I'm going to try a quick experiment and let you know.
My experiment verified that this approach is feasible. However, I immediately ran into security violations caused by the applet sandbox (things like reading system properties are forbidden for unsigned apps). So you will have to sign your One-JAR and allow it permissions to do the forbidden things. I will try to look into making the classloader behave itself inside the applet sandbox, but the need to install and use custom protocol handlers may prove to be a significant/insurmountable problem.
Thanks for looking into the issue.
The applet I am working on now will be signed because it includes native libraries.
I'd like to see the code for the example you tried.
If you look at the jnlp directory in the JRuby samples folder here:
You can see how I setup a simple ant task to create and use a self-signed cert to make it easy for people downloading jruby to experiment with signed and unsigned jars for running JRuby in Java Web Start.
FYI: it would be much easier for me to work on this code (and share patches with you) if it was available in either subversion or git. I use git normally but git can easily read/write/create patches for subversion.
FYI: I'm not expecting you to change because obviously CVS is working for you - but if you were considering changing maybe this could help start the ball rolling ;-)
Hi Stephen: CVS is just a legacy thing, since I started with it six years ato and I haven't needed to change because so far the development has mainly been me. SVN and GitHub would be good choices, but I don't anticipate changing before I release version 1.0 (that would be a good time to do it because there will be some other disruption then). Also, I am using Eclipse which means it doesn't much matter to me what repository is underneath, Eclipse team provider makes them pretty interoperable. If you can use CVS patches would be greatly simplified of course.
I will open an issue in the Bugs tracker and attach a ZIP file showing the project I used to prototype the applet so you can see the tricks needed: there were three. 1) write an applet that invokes Boot.run(new String). Add the applet class to the top-level of the one-jar, 3) create the HTML file to load the applet from the one-jar. Like I said, it cratered at security manager, but signing it with all permissions (or just some permissions) would let you get past it. JarClassLoader is security-manager enabled (or should be, there might be some areas where it doesnt doPrivileged() yet to be discovered.
I signed my TestOneJar.jar for my "test applet" and used you Boot.run() approach and add the applet class to the top-level of TestOneJar.jar and still got "Caused by: java.lang.IllegalArgumentException: Unable to locate com.simontuffs.onejar.Boot in the java.class.path: consider using -Done-jar.jar.path to specify the one-jar filename".
Is it true that OneJar won't work if a JAR is signed?