Hi all!
I have been looking all over the internet for a few days for an example on how to use VBox using XPCOM from a Java program (not using ws).
Does anyone have an example on this that is willing to share, publish or at least point us to it?
Thanks a lot!
Ellis Lombert
java xpcom sample
-
TerryE
- Volunteer
- Posts: 3572
- Joined: 28. May 2008, 08:40
- Primary OS: Ubuntu other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
- Contact:
Examples like this are thin, I'm sorry to say. There are some skeleton ones in the SDK. Try googling for some of the class names. I also use the code from OSE source (Mainly VBoxManage.cpp) to see how to put together the API sequences. OK this is C++, but you can still do the mapping to Java.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
Google your Q site:VirtualBox.org or search for the answer before posting.
The following java code throws the exception:
The code that I am trying to run is this one:
Can any one help me to find out where is the error here?Error al listar las VMs
org.mozilla.xpcom.XPCOMException: The function "createInstanceByContractID" returned an error condition (0x80040154)
at org.mozilla.xpcom.internal.XPCOMJavaProxy.callXPCOMMethod(Native Method)
at org.mozilla.xpcom.internal.XPCOMJavaProxy.invoke(XPCOMJavaProxy.java:143)
at $Proxy1.createInstanceByContractID(Unknown Source)
at EjeVBox.main(EjeVBox.java:25)
The code that I am trying to run is this one:
Code: Select all
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.virtualbox.*;
import org.mozilla.interfaces.*;
import com.sun.xml.internal.bind.v2.runtime.reflect.ListIterator;
import com.sun.xml.ws.commons.virtualbox.*;
public class EjeVBox {
public static void main(String args[])
{
int hr = 0;
nsIServiceManager sm;
org.mozilla.xpcom.Mozilla mozilla = org.mozilla.xpcom.Mozilla.getInstance();
mozilla.initialize(new File("/home/box1/workspace/EjeXul/native/linux/xulrunner/"));
sm = mozilla.getServiceManager();
try{
nsIComponentManager cm = mozilla.getComponentManager();
String NS_VIRTUALBOX_CONTRACTID = "@virtualbox.org/VirtualBox;1";
IVirtualBox virtualBox = (IVirtualBox)cm.createInstanceByContractID(NS_VIRTUALBOX_CONTRACTID, null, null);
listVMs(virtualBox);
mozilla.shutdownXPCOM(sm);
}catch(Exception e){ System.out.println("Error al listar las VMs "); e.printStackTrace(); }
}
static void listVMs(IVirtualBox virtualBox)
{
List<IMachine> lst = new ArrayList<IMachine>();
lst = virtualBox.getMachines2();
if (lst == null) return;
ListIterator<IMachine> it = (ListIterator<IMachine>) lst.listIterator();
try{
while (it.hasNext())
{
IMachine machine = it.next();
if (machine != null)
{
System.out.println("Description: "+machine.getDescription());
System.out.println("GuestProperty: "+machine.getGuestPropertyNotificationPatterns());
System.out.println("Hardware version: "+machine.getHardwareVersion());
System.out.println("Name: "+machine.getName());
System.out.println("Log folder: "+machine.getLogFolder());
System.out.println("Session type: "+machine.getSessionType());
}
}
} catch(Exception ee){ ee.printStackTrace(); }
}
}
-
TerryE
- Volunteer
- Posts: 3572
- Joined: 28. May 2008, 08:40
- Primary OS: Ubuntu other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
- Contact:
This is really one to post on the developers mailing list. However, as far as I read this, in the SDK there are two API interfaces: the webservice and the xpcom interfaces. The kit include the java bindings for the former but not the latter and it is the latter that you are trying to use. The VBox XPCOM is an implementation of Mozilla's XPCOM but it is not the same implementation. You seem to be calling the mozilla implementation which will connect to the Mozilla XPCOM broker, and not the VBox broker. Hence I would expect it to through an unknown source.
Of course I might be entirely wrong. You need to check this with the developers.
Of course I might be entirely wrong. You need to check this with the developers.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
Google your Q site:VirtualBox.org or search for the answer before posting.
-
TerryE
- Volunteer
- Posts: 3572
- Joined: 28. May 2008, 08:40
- Primary OS: Ubuntu other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
- Contact:
To do something like that you will need to write your own custom display handler alongside the existing ones. The VBox architecture allows you to do this -- which is why you can choose between headless and normal integrated displays, but this is a major piece of development.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
Google your Q site:VirtualBox.org or search for the answer before posting.
-
mikebarnacle
- Posts: 2
- Joined: 6. Oct 2009, 05:09
- Primary OS: MS Windows XP
- VBox Version: OSE Debian
- Guest OSses: SPAM_SEARCH
Re: java xpcom sample
I need access to the framebuffer in Java. The webservices API doesn't support this... What can I do?