I am trying to talk to Microsoft Hyper-v server from my java application. Hyper-v provides its interface as WMI classes. My goal is to be able to talk to that server and its virtual machines from my java application. How can I use J-Interop to achieve this?
Can you please show me an example on how J-Interop can be used to instatiate these WMI classes?
I looked at the examples you provided, but pardon me, due to my lack of COM knowledge i could not understand them properly. So I was hoping if u can show me how J-Interop fits in all this, it would be of great help to me.
Appreciate all your help and time.
Thanks and Regards,
Vineela
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Vineela,
The samples show you how to connect with WMI (WBEM Scripting locator). I am not aware of the HyperV interfaces but the general idea of WMI is to get the WBEMServices object to the target machine\namespace you want to work on. HyperV would have provided a set of WMI classes with documentation to what they are and how to access them descriptively (everything in WMI is descriptive). Unfortunately, I am not aware of these. But their usage is no different from what we are doing in the MSWMI example. For starters, you can keep the existing WMI example and just replace your queries. I think that should work.
take care,
best regards,
Vikram
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there anyway to get the same data as property-value pairs, rather than a string representation. Because, with the way it is, even though I can connect to the server, the data being collected is string format which is of not much use to me.
Appreciate all your help.
Thanks and Regards,
Vineela
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Vineela,
I think with GetObjectText_ it would come out as String. We (j-Interop) gets the callee the results as they are. We do not change them in any way.
best regards,
Vikram
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Vikram,
Thanks for the java API to talk to com classes.
I am trying to talk to Microsoft Hyper-v server from my java application. Hyper-v provides its interface as WMI classes. My goal is to be able to talk to that server and its virtual machines from my java application. How can I use J-Interop to achieve this?
Can you please show me an example on how J-Interop can be used to instatiate these WMI classes?
I looked at the examples you provided, but pardon me, due to my lack of COM knowledge i could not understand them properly. So I was hoping if u can show me how J-Interop fits in all this, it would be of great help to me.
Appreciate all your help and time.
Thanks and Regards,
Vineela
Hi Vineela,
The samples show you how to connect with WMI (WBEM Scripting locator). I am not aware of the HyperV interfaces but the general idea of WMI is to get the WBEMServices object to the target machine\namespace you want to work on. HyperV would have provided a set of WMI classes with documentation to what they are and how to access them descriptively (everything in WMI is descriptive). Unfortunately, I am not aware of these. But their usage is no different from what we are doing in the MSWMI example. For starters, you can keep the existing WMI example and just replace your queries. I think that should work.
take care,
best regards,
Vikram
Hi Vikram,
Thanks for the reply. I did follow the MSWMI.java example and was able to connect to hyper-v server and see the instance of the WMI object on it.
However, I have a question with the way the data is being displayed.
In my code, in the MSWMI.java class, these lines
for (int j = 0; j < arrayObj.length; j++)
{
IJIDispatch wbemObject_dispatch = (IJIDispatch)JIObjectFactory.narrowObject(((JIVariant)arrayObj[j]).getObjectAsComObject());
JIVariant variant2 = (JIVariant)(wbemObject_dispatch.callMethodA("GetObjectText_",new Object[]{new Integer(1)}))[0];
System.out.println(variant2.getObjectAsString().getString());
System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
}
Dump the data as a string like below :
instance of Msvm_ComputerSystem
{
CreationClassName = "Msvm_ComputerSystem";
Name = "SUN-STW2K8HV-DP";
};
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Is there anyway to get the same data as property-value pairs, rather than a string representation. Because, with the way it is, even though I can connect to the server, the data being collected is string format which is of not much use to me.
Appreciate all your help.
Thanks and Regards,
Vineela
Hi Vineela,
I think with GetObjectText_ it would come out as String. We (j-Interop) gets the callee the results as they are. We do not change them in any way.
best regards,
Vikram