Class Wmi in Java

Hi, I would like to use WMI library built for java but I don't understand how to recognize the getWMIValue method. In eclipse i have load the jWMI but I get an error. This is the example code:

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

I am still inexperienced in java but if someone can helpme I would be grateful.

Tagged:

Answers

  • Some background for people who don't know what wmi is:

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

  • but I get an error.

    What, really, is the point of saying you get an error but not saying what the error is? Are we meant to guess?

  • You're right. I used just one web page. I imported the folder that contains the jmic class but do not understand how to properly execute the command line.

  • The error code is: Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method getWMIValue(String, String) is undefined for the type test

  • And how are you calling it?

  • I have imported the folder classe in project-build path-configure build path. Then I have wrote in the code import jwmi.* Is It correct?

  • no idea.

    normally you'd need to call a method on a class, ie str.toUpperCase();

    your example

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

    doesn't do that. it's possible that that's a static method. normally you'd call this using a class name - String.format(...). and you can drop the String if you use a static import. but i have no idea how he coded it...

    ok, the source says:
    package com.citumpe.ctpTools;

    and the file:
    public class jWMI

    and the method is: public static String getWMIValue(String wmiQueryStr, String wmiCommaSeparatedFieldName) throws Exception

    so try
    import static com.citumpe.ctpTools.jWMI.*;

    or use jWMI.getWMIValue("Select Name from Win32_ComputerSystem", "Name");

  • that's based on the code from here:
    http://henryranch.net/software/jwmi-query-windows-wmi-from-java/

    if you are using a different library then it'll be different.

  • (again, you don't say what library you are using. you say you have an error but don't say what it is, you say you are using a library but don't say exactly what it is or where it's from. you are vague about your code. you don't exactly make it easy for us to help...)

Sign In or Register to comment.