How to control the virtualbox vms through java cod

2019-08-28 15:30发布

问题:

Java API to control the virtualbox is not working. i am not getting the initial steps of configuration. I am stuck in the installation of JACOB: a java to COM bridge. After running the code following error appears : The method startVm(String, null, int) is undefined for the type VirtualBoxManager

i have added the vboxjxpcom.jar in external library of eclipse and set the path but i don't know how to install JACOB as it has no exe file. If there is a any useful tutorial on it please share it's link.

public class testVbox {
    public static void main(String[] args) {
        VirtualBoxManager virtualBoxManager = VirtualBoxManager.createInstance(null);
        IVirtualBox vbox = virtualBoxManager.getVBox();
        List<IMachine> machines= vbox.getMachines();

        for (IMachine m : machines) {
            System.out.println("Name: " + m.getName() + " OS: " + m.getOSTypeId());
            virtualBoxManager.startVm(m.getName(), null, 7000); //Starting a VM

        virtualBoxManager.cleanup();
    }

}

my desired outcome should be that when i run a code in eclipse it should open the vm(virtual machine) in virtualbox.

标签: virtualbox