How do I configure the icedtea-plugin package for ubuntu precise in such a way that it executes all applets with a specific memory limit by default? Preferrably using command line tools and no graphical user interface.
I'm building a kiosk setup using java applets, and would like to increase the default memory limit for all these applets. The kiosk is based on ubuntu linux, using the icedtea-plugin package as a browser plugin. As building the kiosk is automated and headless, I'd rather configure it from the command line if possible.
Here is what I've found out so far:
-Xmx…
command line argument which will be used when starting the java virtual machine for the plugin.<param name="java_arguments" value="-Xmx…">
.
But that would mean modifying all my HTML files, which I'd rather avoid. And there is a good chance that I'd have to sign my code to make this work, which adds quite a lot of problems in other places of my project.ControlPanel
which I can use to set these command line switches. It seems that the configuration gets written to a file ~/.java/deployment/deployment.properties
, where it is associated with the key deployment.javaws.jre.0.args
.0
seems to refer to one specific JVM, as represented in one row of the table in the control panel. For each JVM, there are several values besides this args
value, all sharing a common index number.~/.icedtea/
. Not sure whether that means ~/.icedtea/deployment.properties
or rather ~/.icedtea/deployment/deployment.properties
. IcedTea does not seem to come with a ControlPanel
.As you can see, there are many hints as to how this might work, but so far I haven't seen any definite answer as to what will work. There are still many open questions:
deployment
in the path?args
value even supported by OpenJDK, even if it is not described in the corresponding specification?I guess I could try out all possible combinations to see whether one of them works, but doing so will take considerable time. So I'm asking here, to see if someone has experience in this, and can provide a quiecker answer. If not, I guess I'll answer my own question eventually, once I've tried things the hard way.
I just had a look at the source code of the icedtea-web plugin. The part of the code which builds the command line seems to have no provision at all for including custom arguments, no matter their origin. So it does not matter which config files, HTML files or environment variables I edit, the code there will build the same command line to call java, disregarding all my whishes.
So if all configuration fails, what remains is hackery. One approach would be to patch the source code of the plugin, and make it include additional words into its command line. For a static addition, i.e. a single size change, this would be fairly easy. A more general fix would include the content of some environment variable, the way Peter's answer suggests. That would mean word-splitting the environment variable in question, and allocating the space for the array of words dynamically. Quite a bit of work at the C level.
As an alternative, one could tackle this at the level of the executed binary. The plugin apparently has the path of the executable hard-coded into it. In my case, this path is /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java
. One can rename that binary to java.orig
, and put a shell script in its place, with the following content:
#!/bin/bash
for i in "$@"; do
if [[ "${i}" == sun.applet.PluginMain ]]; then
exec "$0.orig" -Xmx512m "$@"
fi
done
exec "$0.orig" "$@"
One consequence of this approach is the fact that ps
will no longer print these applets as java
but instead as java.orig
. Should not be a problem in most cases.