Small JVM named Jamvm
18 Jan 2010Some of you may have heard about Jamvm, for all others, Jamvm is an very small opensource JVM. You may ask your self why do I need it, now there are couple of reasons you would like to use Jamvm. For example you want to run java on an mobile device or a router with very limited space on it, or you want to distribute your Java application but don’t want to depend on installed Java. At the end possibilities are endless. In this post I am going to show you how to compile and use JVM.
To use Jamvm we need to download and compile it:
The default installation location is /usr/local. If you need more info or want to change options please look in to the INTALL doc.
Now that we have jamvm compiled we need to make it work. Jamvm uses GNU classpath. GNU classpath is available as source here but can be also installed as binary:
I was going to show you how to compile GNU classes here but after countless tries on my own machine with different java versions I just gave up, I could not get it to compile. To get it to work I just installed the binary version and used that.
To show you how jamvm works and to show you that you can bring it’s complete size down I create an zip file. The zip contains the following:
HelloWorldApp = prints Hello World
jamvm = jamvm binary
run.sh = bash script to run HelloWorlApp
classes.zip = zip file containing classes needed by jamvm
glibj.zip = gnu classpath classes, I striped this from 9MB to 1.3MB in 5 minutes, you can go further by only using what you really really need.
3x.so = 3 so libraries needed by jamvm, these are from my 64bit Ubuntu machine
Just run run.sh and you will see “Hello World!”
Some additional info, I tried adding HelloWorldApp to classpath so jamvm can run it but for some reason I needed to add it to -Xbootclasspath instead of classpath.