[vbox-dev] SDK sample compilation issue

Gerry Egan gerry.egan6 at gmail.com
Fri Jan 15 22:27:27 GMT 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20100115/d81fe670/attachment.html>


More information about the vbox-dev mailing list