[vbox-dev] SDK sample compilation issue

Achim Hasenmueller achim at sun.com
Sat Jan 16 08:38:30 GMT 2010


Your code should read:

>                IConsole oConsole = oSession.getConsole();


Achim

On Jan 15, 2010, at 23:27 , Gerry Egan wrote:

> Hello,
> 
> 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. 
> 
> 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. 
> 
> Any help or guidance that you can provide to me would be greatly appreciated.
> 
> My setup:
> VBox and SDK version: 3.1.2
> Java version: Version 6 Update 17
> Host OS: Windows Server 2003 SP2
> Guest OS: Ubuntu 9.1 
> 
> Method I'm adding to clienttest.java (slightly modified version of startVM in the same file):
> 
>     public void stopVM(String strVM)
>     {
>         ISession oSession = null;
>         IMachine oMachine = null;
> 
>         try
>         {
>             oSession = mgr.getSessionObject(vbox);
> 
>             // first assume we were given a UUID
>             try
>             {
>                 oMachine = vbox.getMachine(strVM);
>             }
>             catch (Exception e)
>             {
>                 try
>                 {
>                     oMachine = vbox.findMachine(strVM);
>                 }
>                 catch (Exception e1)
>                 {
>                 }
>             }
> 
>             if (oMachine == null)
>             {
>                 System.out.println("Error: can't find VM \"" + strVM + "\"");
>             }
>             else
>             {
>                 String uuid = oMachine.getId();    
>                 vbox.openExistingSession(oSession,uuid);
>                 IConsole oConsole = oSession.console;
>                 IProgress oProgress = oConsole.powerDown();        
>                 oProgress.waitForCompletion(10000);
>                 
>                 long rc = oProgress.getResultCode();
>                 if (rc != 0)
>                    System.out.println("Session failed!");
>             }
>         }
>         catch (Exception e)
>         {
>             e.printStackTrace();
>         }
>         finally
>         {
>             if (oSession != null)
>             {
>                 oSession.close();
>             }
>         }
>     }
> 
> 
> 
> Java Output:
> 
> clienttest1.java:252: cannot find symbol
> symbol  : variable console
> location: class com.sun.xml.ws.commons.virtualbox_3_1.ISession
>                                 IConsole oConsole = oSession.console;
>                                                             ^
> 1 error
> 
> 
> _______________________________________________
> vbox-dev mailing list
> vbox-dev at virtualbox.org
> http://vbox.innotek.de/mailman/listinfo/vbox-dev





More information about the vbox-dev mailing list