Problems with Java-Bindings on Win7 over COM/XPCOM

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
torn8
Posts: 3
Joined: 16. Feb 2014, 23:21

Problems with Java-Bindings on Win7 over COM/XPCOM

Post by torn8 »

Hey guys,

I want to control my VBox on a Windows 7 machine with Java over COM/XPCOM.
I added vboxjxpcom.jar to my Classpath and I also set the vbox.home property correctly.

However I get the following error:

Code: Select all

Exception in thread "main" java.lang.UnsatisfiedLinkError: no vboxjxpcom in java.library.path
	at java.lang.ClassLoader.loadLibrary(Unknown Source)
	at java.lang.Runtime.loadLibrary0(Unknown Source)
	at java.lang.System.loadLibrary(Unknown Source)
	at org.mozilla.xpcom.internal.JavaXPCOMMethods.registerJavaXPCOMMethods(JavaXPCOMMethods.java:66)
	at org.mozilla.xpcom.internal.MozillaImpl.initialize(MozillaImpl.java:48)
	at org.mozilla.xpcom.Mozilla.initialize(Mozilla.java:669)
	at org.virtualbox_4_3.VirtualBoxManager.createInstance(VirtualBoxManager.java:110)
	at de.xxxx.tests.MainConnector.main(MainConnector.java:12)
It seems to me that he want to have a vboxjxpcom.dll in the lib-path, however I couldn't find a such file at SDK- or VBox-folder.

Do you have a suggestion for me?

Thanks a lot!
torn8

PS: My Java-Code:

Code: Select all

import org.virtualbox_4_3.IVirtualBox;
import org.virtualbox_4_3.VirtualBoxManager;


public class MainConnector {
   public static void main(String[] args) {
	   
	   
	   System.setProperty("vbox.home", "C:\\Program Files\\Oracle\\VirtualBox");
   VirtualBoxManager mgr = VirtualBoxManager.createInstance(null);
   
   IVirtualBox vbox = mgr.getVBox();
   System.out.println("VirtualBox version: " + vbox.getVersion() + "\n");

   // get first VM name
   String m = vbox.getMachines().get(0).getName();
   System.out.println("Attempting to start VM " + m);

   // start it
   //mgr.startVm(m, null, 7000);
   mgr.cleanup();
   }
}
VBox + SDK - Version: 4.3.6-91406
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Problems with Java-Bindings on Win7 over COM/XPCOM

Post by noteirak »

XPCOM is for everything except Windows. (MS)COM is what you need for Windows. Read section 1.2 & 2.3 of the SDK PDF.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
torn8
Posts: 3
Joined: 16. Feb 2014, 23:21

Re: Problems with Java-Bindings on Win7 over COM/XPCOM

Post by torn8 »

Thx a lot for your reply, noteirak. :)

I also tried to do it this way, however I couldn't find the vboxjmscom.jar-file. Where is it located?
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Problems with Java-Bindings on Win7 over COM/XPCOM

Post by noteirak »

AFAIK there are no Java binding for MS COM, but I never used MSCOM so I can't tell you precisely. At least, nothing like that is found in the SDK package, and I always went the webservices route while being on Windows.
There is a sample file inside the SDK ZIP under /sdk/bindings/mscom/samples, and it seems to only use COM & C/C++.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
torn8
Posts: 3
Joined: 16. Feb 2014, 23:21

Re: Problems with Java-Bindings on Win7 over COM/XPCOM

Post by torn8 »

I've found a solution.

You have to compile VBox with VBOX_WITH_JMSCOM=1.

Can anybody provide a valid vboxjmscom_4.3.jar-file? I don't want to compile VBox just because of this file... :(

Thank you very much in advance.

torn8
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Problems with Java-Bindings on Win7 over COM/XPCOM

Post by noteirak »

Oh nice one, wasn't aware of this build option. For the jar, you're better of asking directly on the dev mailing list, so you get an official build jar, instead of a SVN one.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Post Reply