Problem with CloneMode

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
Wldz
Posts: 9
Joined: 31. Dec 2014, 02:39

Problem with CloneMode

Post by Wldz »

Hello.
I am using virtualbox api 4.3 in java and i am trying to clone a machine using this piece of code. But, i am having problem in making a list of cloneoptions enumeration. I am unable to add cloneoptions.KeepAllMACs in to the list.

Code: Select all

IMachine m = vbox.getMachines().get(0);
        String ostype = m.getOSTypeId();
        ISession iSession = mgr.getSessionObject();
        vbox.getMachines().get(0).lockMachine(iSession, LockType.Shared);
        IMachine mac = vbox.createMachine(vbox.composeMachineFilename("Wal",null,null,"/home/waleed/Documents"),"Waleed", null, ostype,"forceOverwrite=1");
        mac.saveSettings();

	List<CloneOptions> cloneOptionsList = new ArrayList<CloneOptions>();
        cloneOptionsList.add(CloneOptions.KeepAllMACs); // i am having problems here

        IProgress progr =  m.cloneTo(mac, CloneMode.MachineState,cloneOptionsList);
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: Problem with CloneMode

Post by noteirak »

No problem here, what is the error exactly?
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Wldz
Posts: 9
Joined: 31. Dec 2014, 02:39

Re: Problem with CloneMode

Post by Wldz »

Actually my Eclipse compiler gives me the syntax error.
The method add(CloneOptions) in the type List<CloneOptions> is not applicable for the arguments (List<CloneOptions>)
please help me out i am stuck at this :cry:
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: Problem with CloneMode

Post by noteirak »

I am guessing you imported the wrong class - there are always two classes, the interface type, and the actualy implementation depending on the connector you use. Can't be sure since you don't post the full file content.
Make sure you import org.virtualbox_4_3.CloneOptions and only that one.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Wldz
Posts: 9
Joined: 31. Dec 2014, 02:39

Re: Problem with CloneMode

Post by Wldz »

THANKS A LOT...

Yeah you were right I was importing the wrong class :( .... You made my day..

Thanks Again Bro :)
Post Reply