Version 5 (modified by 17 years ago) (diff) | ,
---|
Using BOINC with Java applications
Use JSmooth
JSmooth is an open-source tool for converting Java applications to Windows .exe files. To quote from their web site:
JSmooth is a Java Executable Wrapper. It creates native Windows launchers (standard .exe) for your Java applications. It makes Java deployment much smoother and user-friendly, as it is able to find any installed Java VM by itself. When no VM is available, the wrapper can automatically download and install a suitable JVM, or simply display a message or redirect the user to a web site.
How to run a java app with BOINC - a simple wrapper approach without using BOINC api
(for windows hosts only, because of jsmooth)
You need:
- The wrapper application from boinc_samples
- the boinc_zip library
- a Java Virtual Machine. You'll find it e.g. in c:\Program Files\Java\jre<version>
- Jsmooth to generate a launcher. Use version 0.9.9-6, since version 0.9.9-7 has a bug: every time it runs, a (small) jar file is left behind in the temp directory of the users machine..
What needs to be done:
- Create a launcher for your executable jar file using JSmooth (just a launcher, don't wrap everything into one exe file.. otherwise JSmooth extracts the whole app into a temp dir every time the app runs, and the files are only deleted on reboot).
- Use the wrapper to start the launcher you created.
- JSmooth has a lot of options, and some of them are important for everything to run smoothly, so it's probably best to test the application at this stage in an environment where you know that all computers have java installed.
- We recommend the a configuration similar to this:
<?xml version="1.0" encoding="ISO-8859-1"?> <jsmoothproject> <JVMSearchPath>registry</JVMSearchPath> <JVMSearchPath>javahome</JVMSearchPath> <JVMSearchPath>jrepath</JVMSearchPath> <JVMSearchPath>jdkpath</JVMSearchPath> <JVMSearchPath>exepath</JVMSearchPath> <JVMSearchPath>jview</JVMSearchPath> <bundledJVMPath>jre</bundledJVMPath> <classPath>YourJavaApplication.jar</classPath> <embeddedJar>false</embeddedJar> <executableName>YourLauncherApp.exe</executableName> <initialMemoryHeap>-1</initialMemoryHeap> <mainClassName>MainClassOfYourJavaApp</mainClassName> <maximumMemoryHeap>-1</maximumMemoryHeap> <maximumVersion></maximumVersion> <minimumVersion></minimumVersion> <skeletonName>Autodownload Wrapper</skeletonName> <skeletonProperties> <key>Message</key> <value><![CDATA[ Message to users when finding a jvm fails ]]> </value> </skeletonProperties> <skeletonProperties> <key>DownloadURL</key> <value>http://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab</value> </skeletonProperties> <skeletonProperties> <key>SingleProcess</key> <value>1</value> </skeletonProperties> <skeletonProperties> <key>Debug</key> <value>0</value> </skeletonProperties> </jsmoothproject>
- Make a copy of the folder containing the jvm. Recursively remove all write protections on files and folders. This is very important! If you don't do that, the boinc client will not be able to delete it after completing the workunit and fill up the whole harddisk very quickly.
- Read the licence information files inside the jvm. One of them contains a list of files which can be deleted to make the jvm a bit smaller. Then zip that folder to e.g. "jre.zip" and add it to your application.
- Use boinc_zip from within the wrapper application by adding something like this to wrapper.C :
string inzip; boinc_resolve_filename_s("jre.zip",inzip); string outzip("jre"); if(boinc_zip(UNZIP_IT, inzip, outzip)) fprintf(stderr, "unzipping failed\n");
- make sure the jmooth launcher lookes for an "embedded" jvm in the folder that you unzip to from the wrapper.
- that's it. Since it is not possible to use the boinc api from within the java application, it would be polite to let the users opt out of running your application, e.g. if they have a lot of suspend/resume events..