Does there exist a way by which i can use WMI classes in java

12,758

Solution 1

JavaScript and Java aren't the same thing.

JavaScript

JavaScript is available under Windows Scripting Host (WSH). With it, it is fairly easy to access WMI:

var loc = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = loc.ConnectServer(".", "root\\cimv2");
coll = svc.ExecQuery("select * from Win32_Process");
var items = new Enumerator(coll);

while ( !items.atEnd() )
{
    WScript.Echo(items.item().Name);
    items.moveNext();
}

jWMI (Java)

jWMI is a small library to enable Java to make general WMI queries. It seems to be available here

http://henryranch.net/software/jwmi-query-windows-wmi-from-java/

It also seems easy to use (though I am not sure how powerful or complete it is):

String name = getWMIValue("Select Name from Win32_ComputerSystem", "Name");

WBEM (Java)

WMI is a Microsoft implementation of Web Based Enterprise Management (WBEM). There is also a Java implementation of general WBEM which will be at some level compatible with WMI.

This might be the most complete true Java implementation you're going to find. If your needs are above tiny scripting (such as implementing a WBEM/WMI provider), then you might want to look into this option.

Solution 2

I have successfully used WMI through JACOB

Solution 3

For the scripting language: Download Scriptomatic 2.0 and let the wizard create WMI code for VBScript, JScript, Perl, and Python. Here is something similar for Powershell.

Solution 4

You might want to check J-Interop too. Here's a nice example: http://www.vijaykandy.com/2009/09/windows-management-instrumentation-wmi-from-java/

Solution 5

JWMI performing WMI operations by creating and executing vb scripts with the relevant queries.
I am using J-Interop which is an open source and a good option.
There are also JACOB, J-Integra and EZ Jcom.

Share:
12,758
amod
Author by

amod

I am a software developer with strong desire to learn and work on new technologies and solve complex problems with my solid programming knowledge and analytical skills. Currently, I am a Software Developer at Honeywell, Atlanta. I did Master in Computer Science from Lamar University, USA. I had worked as a Senior R&D Engineer in Nokia Networks for 2+ years and before that, I was a software developer in Persistent Systems Ltd for 2 years. In Nokia Networks I was part of core R&D team which design and implement complex telecommunication related algorithms to optimize the mobile network. While working, along with honing my programming skills, I became adept at analytical thinking, debugging, troubleshooting and team working. My core responsibilities also contain guiding junior developer to complete the task provided to them. I like writing code to make day to day life easier. Apart from coding my hobby is to write Blogs I used to write Blogs on various technology available on internet, games, gadgets, social networking, software, Cloud-based applications. I like reading blogs as well, exploring software products and gadgets. I am also a founding member of website CampFestiva.com which publish college events happening all over India. I have been working hard on this for more than 3+ years to make it what it is now. Campfestiva is a non-profitable attempt to provide information about various opportunities to students in India.

Updated on June 24, 2022

Comments

  • amod
    amod about 2 years

    Hi i want to use WMI classes to find out the application and products information. But the problem is that i want to use java or any scripting language like python, javascript or perl. I have heard about JWMI, it may be an option. Can anyone help me regarding this???

  • Arslan Ahmed
    Arslan Ahmed about 4 years
    how to get the disk manufacturing serial? device id and another thing related to disk?