Java application as standalone executable
Java application cosnsists of
Java Virtual Machine (JVM) and set of Java classes. JVM can
be packaged as executable or be embedded in other application.
Example of stand-alone JVM executable is java launcher,
bundled with Java Development Kit (JDK). JVM is embedded
in Java-capable browser and server. It is possible to write
customized JVM wrapper - standard Java includes Java Native Interface
(JNI) implementation, providing two-way interaction between C/C++ and
Java classes can be delivered as
set of files , archives or fetched over the network. It is possible
to let JVM to get Java classes from any source. The mechanism for
extending is called class loader
Java application as combination of launcher and set of files poses
security and maintaince problem - files with Java code has to be
installed, launcher has to be aware of their exact location, etc. The paper
discusses the solution that, by combining customized launcher
and in-memory class loader, enables delivering Java application as single
The solution consists of two sets
of utilities: Java classes converter and customized launcher.
Java class converter takes Java classes packaged in standard form -
as directory structure or archive ( jar ) files and outputs the
same classes as object file. To make implementation more portable,
intermediate file format is employed - intermediate file can be created
in C or assembler programming languages.
Generated code is array of data, representing
Java classes byte code. The code is linked with customized launcher, making
bytecode available throw regular C references.
Customized launcher works
in two phazes: first, in-memory class loader itself is loaded in JVM; then
reference to converted and compiled Java classes is passed down the
in-memory class loader, making compiled Java classes available for JVM.
In-memory class loader is also Java
class, converted into compilable form and linked with launcher.
Utilities source code, as well as sample
launcher is available for browsing from here