[vbox-dev] Java XPCOM SDK NullPointerException

Jan Dillmann derjan at devzero.de
Mon May 30 13:17:19 GMT 2011

Hello list,

for my current university project, I need to access VirtualBox instances using the vboxjxpcom.jar .

However, I can't even get the minimal sample running. The following code

	public static void main(String[] args) {
		System.setProperty("vbox.home", "/Applications/VirtualBox.app/Contents/MacOS");

		VirtualBoxManager mgr = VirtualBoxManager.createInstance(null);

		IVirtualBox vbox = mgr.getVBox(); 
		System.out.println("VirtualBox version: " + vbox.getVersion()); 

crashes at "VirtualBoxManager.createInstance" with the following exception:

Exception in thread "main" java.lang.NullPointerException
	at org.mozilla.xpcom.Mozilla.initialize(Mozilla.java:632)
	at org.virtualbox_4_0.VirtualBoxManager.createInstance(VirtualBoxManager.java:104)
	at Main.main(Main.java:15)

I'm developing with Eclipse Helios and Java 1.6 on a Mac OS X 10.6 using the latest VirtualBox and jar (4.0.8).

Does anyone know how I can fix this? The jar is in the classpath and the vbox.home-Property is set.

Thanks in advance,

More information about the vbox-dev mailing list