Update JavaApps.md file

Signed-off-by: Vitalii Koshura <lestat.de.lionkur@gmail.com>
Vitalii Koshura 2023-04-07 00:04:13 +02:00
parent 7e2fc49479
commit fbe0e347e6
No known key found for this signature in database
GPG Key ID: CE0DB1726070A5A3
1 changed files with 64 additions and 62 deletions

@ -1,20 +1,22 @@
# How to run a java app with BOINC - a simple wrapper approach without using BOINC api # Using BOINC with Java applications
## How to run a java app with BOINC - a simple wrapper approach without using BOINC api
(for windows hosts only, because of jsmooth) (for windows hosts only, because of jsmooth)
You need: You need:
- The [wrapper](WrapperApp) application from boinc/samples. Make sure it's the latest version. - The [wrapper](WrapperApp) application from boinc/samples. Make sure it's the latest version.
- The [boinc_zip](FileCompression#boinc-zip) library - The [boinc_zip](FileCompression#boinc-zip) library
- A Java Virtual Machine to distribute with your science application. On a windows PC with Java installed, you'll usually find it e.g. in c:\Program Files\Java\jre<version> - A Java Virtual Machine to distribute with your science application. On a windows PC with Java installed, you'll usually find it e.g. in c:\Program Files\Java\jre\<version>
- [Jsmooth](http://jsmooth.sourceforge.net/) 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. - [Jsmooth](http://jsmooth.sourceforge.net/) 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: What needs to be done:
- Create a launcher for your executable jar file using JSmooth (Use the JSmooth option to just create 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). - Create a launcher for your executable jar file using JSmooth (Use the JSmooth option to just create 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](WrapperApp) to start the launcher you created. - Use the [wrapper](WrapperApp) 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. - 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: - We recommend the a configuration similar to this:
```
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<jsmoothproject> <jsmoothproject>
<JVMSearchPath>registry</JVMSearchPath> <JVMSearchPath>registry</JVMSearchPath>
<JVMSearchPath>javahome</JVMSearchPath> <JVMSearchPath>javahome</JVMSearchPath>
<JVMSearchPath>jrepath</JVMSearchPath> <JVMSearchPath>jrepath</JVMSearchPath>
@ -52,22 +54,22 @@ What needs to be done:
<key>Debug</key> <key>Debug</key>
<value>0</value> <value>0</value>
</skeletonProperties> </skeletonProperties>
</jsmoothproject> </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.
- 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 license information files inside the jvm. One of them contains a list of files which can be deleted to make the jvm a bit smaller. (What you want to remove is application-specific, but you may find this a useful starting point: http://www.malariacontrol.net/download/jre.zip). Then zip that folder to e.g. "jre.zip" and add it to your application. - Read the license information files inside the jvm. One of them contains a list of files which can be deleted to make the jvm a bit smaller. (What you want to remove is application-specific, but you may find this a useful starting point: http://www.malariacontrol.net/download/jre.zip). 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.cpp: - Use boinc_zip from within the wrapper application by adding something like this to wrapper.cpp:
```
string inzip; string inzip;
boinc_resolve_filename_s("jre.zip",inzip); boinc_resolve_filename_s("jre.zip",inzip);
string outzip("jre"); string outzip("jre");
if(boinc_zip(UNZIP_IT, inzip, outzip)) if(boinc_zip(UNZIP_IT, inzip, outzip))
fprintf(stderr, "unzipping failed\n"); fprintf(stderr, "unzipping failed\n");
```
- Make sure the jmooth launcher looks for an "embedded" jvm in the folder that you unzip to from the wrapper.
- Make sure the jmooth launcher looks 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.
- 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.