Hello,<br><br>I am currently trying to modify the sample code supplied with the SDK in order to get a better understanding of the API as I plan to write a program that will need to manipulate VMs in Java. I am trying to add a stopvm method to clienttest.java in the jax-ws sample directory of the sdk. I understand that to power down a vm I need to call the powerDown() method from the console object that is created as an attribute of the session object when the openExistingSession() method is called. However when I try and compile the following example Java cannot find the session objects console attribute. <br>
<br>I have reinstalled the SDK and I can compile and run clientest.java unmodified. but this problem persists. I would not be asking you if I had not already looked through the SDK manual and source code for the solution to the problem. <br>
<br>Any help or guidance that you can provide to me would be greatly appreciated.<br>
<br>My setup:<br>VBox and SDK version: 3.1.2<br>Java version: Version 6 Update 17<br>Host OS: Windows Server 2003 SP2<br>Guest OS: Ubuntu 9.1 <br><br>Method I'm adding to clienttest.java (slightly modified version of startVM in the same file):<br>
<br> public void stopVM(String strVM)<br> {<br> ISession oSession = null;<br> IMachine oMachine = null;<br><br> try<br> {<br> oSession = mgr.getSessionObject(vbox);<br><br> // first assume we were given a UUID<br>
try<br> {<br> oMachine = vbox.getMachine(strVM);<br> }<br> catch (Exception e)<br> {<br> try<br> {<br> oMachine = vbox.findMachine(strVM);<br>
}<br> catch (Exception e1)<br> {<br> }<br> }<br><br> if (oMachine == null)<br> {<br> System.out.println("Error: can't find VM \"" + strVM + "\"");<br>
}<br> else<br> {<br> String uuid = oMachine.getId(); <br> vbox.openExistingSession(oSession,uuid);<br> IConsole oConsole = oSession.console;<br>
IProgress oProgress = oConsole.powerDown(); <br> oProgress.waitForCompletion(10000);<br> <br> long rc = oProgress.getResultCode();<br> if (rc != 0)<br>
System.out.println("Session failed!");<br> }<br> }<br> catch (Exception e)<br> {<br> e.printStackTrace();<br> }<br> finally<br> {<br>
if (oSession != null)<br> {<br> oSession.close();<br> }<br> }<br> }<br><br><br><br>Java Output:<br><br>clienttest1.java:252: cannot find symbol<br>symbol : variable console<br>
location: class com.sun.xml.ws.commons.virtualbox_3_1.ISession<br> IConsole oConsole = oSession.console;<br> ^<br>1 error<br><br><br>