<span id="result_box" class="" lang="en"><span class="hps">Hello,</span> <span class="hps">I am</span> <span class="hps">beginner</span> <span class="hps">in </span></span><span id="result_box" class="" lang="en"><span class="hps">virtualbox</span></span><span id="result_box" class="" lang="en"><span class="hps"></span> <span class="hps">java</span> <span class="hps">API</span><span class="hps"></span> <span class="hps">and now</span> <span class="hps">I need</span><br>

 <span class="hps">change the</span> <span class="hps">memory size of</span> <span class="hps">a</span> <span class="hps">vm.</span> <span class="hps">I am</span> <span class="hps">using the following code</span><span>:</span><br>

<br>    public void setMemorySize() {<br>        VirtualBoxManager mgr = VirtualBoxManager.createInstance(null);<br>        ISession session = mgr.getSessionObject();<br>        IVirtualBox vbox = mgr.getVBox();<br>        <br>

        IMachine machine = vbox.getMachines().get(1);<br>        IProgress progress = machine.launchVMProcess(session, &quot;gui&quot;, &quot;&quot;);<br>        progress.waitForCompletion(-1);<br>        machine.lockMachine(session, LockType.Write); // machine is now locked for writing<br>

        IMachine mutable = session.getMachine();<br>        // obtain the mutable machine copy<br>        mutable.setMemorySize((long) 1024);<br>        mutable.saveSettings();<br>        // write settings to XML<br>        session.unlockMachine();<br>

    }<br><br> <span class="hps">But</span><span class="">, returns the</span> <span class="hps">following error</span><span class="">:</span></span><br><br>Exception in thread &quot;main&quot; org.virtualbox_4_1.VBoxException: The function &quot;lockMachine&quot; returned an error condition: &quot;The given session is busy&quot;  (0x80bb0007)<br>

    at org.virtualbox_4_1.IMachine.lockMachine(IMachine.java:798)<br>    at teste.elasticidade.IniciaVM.setMemorySize(IniciaVM.java:51)<br>    at teste.elasticidade.IniciaVM.main(IniciaVM.java:37)<br><br clear="all"><br>
<span id="result_box" class="short_text" lang="en"><span class="hps">what may</span> <span class="hps">be happening?<br>
<br>thanks a lot.<br></span></span><br>-- <br>Rafael Braga<a href="http://www.linkedin.com/myprofile?trk=hb_tab_pro" target="_blank"></a><br><br>