This section describes how to use the javax.wbem.client APIs to request operations and to perform common programming tasks.
Use the newInstance method to create an instance of an existing class. If the existing class has a key property, the application must set the key property to a unique value. As an option, an instance can define additional qualifiers that are not defined for the class. These qualifiers can be defined for the instance or for a particular property of the instance. The qualifiers do not need to appear in the class declaration.
Applications can use the getQualifiers method to get the set of qualifiers that are defined for a class.
This example uses the newInstance method to create a Java class representing a CIM instance, for example, a Solaris package, from the Solaris_Package class.
... { /*Connect to the CIM Object Manager in the root\cimv2 namespace on the local host. Specify the username and password of an account that has write permission to the objects in the root\cimv2 namespace. */ UserPrincipal up = new UserPrincipal("root"); PasswordCredential pc = new PasswordCredential("root-password"); /* Connect to the namespace as root with the root password. */ CIMClient cc = new CIMClient(cns, up, pc); ... // Get the Solaris_Package class cimclass = cc.getClass(new CIMObjectPath("Solaris_Package"), true, true, true, null); /* Create a new instance of the Solaris_Package class populated with the default values for properties. If the provider for the class does not specify default values, the values of the properties will be null and must be explicitly set. */ CIMInstance ci = cc.createInstance (new CIMObjectPath("Solaris_Package"), ci); } ...
Use the deleteInstance method to delete an instance.
The example does the following:
Connects the client application to the CIMOM
Uses CIMObjectPath to construct an object containing the CIM object path of the object to be deleted
Calls enumerateInstance to get the specified instance and all instances of its subclasses
Calls deleteInstance to delete each instance
import java.rmi.*; import java.util.Enumeration; import javax.wbem.cim.CIMClass; import javax.wbem.cim.CIMException; import javax.wbem.cim.CIMInstance; import javax.wbem.cim.CIMNameSpace; import javax.wbem.cim.CIMObjectPath; import javax.wbem.client.CIMClient; import javax.wbem.client.PasswordCredential; import javax.wbem.client.UserPrincipal; /** * Returns all instances of the specified class. * This example takes five arguments: hostname (args[0]), username * (args[1]), password (args[2]) namespace (args[3] and classname (args[4]) * It will delete all instances of the specified classname. The specified * username must have write permissions to the specified namespace */ public class DeleteInstances { public static void main(String args[]) throws CIMException { CIMClient cc = null; // if not five arguments, show usage and exit if (args.length != 5) { System.out.println("Usage: DeleteInstances host username " + "password namespace classname "); System.exit(1); } try { // args[0] contains the hostname and args[3] contains the // namespace. We create a CIMNameSpace (cns) pointing to // the specified namespace on the specified host CIMNameSpace cns = new CIMNameSpace(args[0], args[3]); // args[1] and args[2] contain the username and password. // We create a UserPrincipal (up) using the username and // a PasswordCredential using the password. UserPrincipal up = new UserPrincipal(args[1]); PasswordCredential pc = new PasswordCredential(args[2]); // Connect to the CIM Object Manager and pass it the // CIMNameSpace, UserPrincipal and PasswordCredential objects // we created. cc = new CIMClient(cns, up, pc); // Get the class name (args[4]) and create a CIMObjectPath CIMObjectPath cop = new CIMObjectPath(args[4]); // Get an enumeration of all the instance object paths of the // class and all subclasses of the class. An instance object // path is a reference used by the CIM object manager to // locate the instance Enumeration e = cc.enumerateInstanceNames(cop); // Iterate through the instance object paths in the enumeration. // Construct an object to store the object path of each // enumerated instance, print the instance and then delete it while (e.hasMoreElements()) { CIMObjectPath op = (CIMObjectPath)e.nextElement(); System.out.println(op); cc.deleteInstance(op); } // end while } catch (Exception e) { // if we have an exception, catch it and print it out. System.out.println("Exception: "+e); } // end catch // close session. if (cc != null) { cc.close(); } } }
Client applications commonly use the getInstance method to retrieve CIM instances from the CIMOM. When an instance of a class is created, the class inherits the properties of all the parent classes in its class hierarchy. The getInstance method takes the Boolean argument localOnly.
If localOnly is true, getInstance returns only the noninherited properties in the specified instance. The noninherited properties are defined in the instance.
If localOnly is false, all properties in the class are returned. These properties include those properties that are defined in the instance, and all properties inherited from all parent classes in its class hierarchy.
Use the setInstance method to update an existing instance.
This example does the following:
Gets instances of an object path in an enumeration
Updates the property value of b to 10 in each instance
Passes the updated instances to the CIMOM
... { // Create an object path, an object that contains the CIM name for // "myclass" CIMObjectPath cop = new CIMObjectPath("myclass"); /* Get instances for each instance object path in an enumeration, update the property value of b to 10 in each instance, and pass the updated instance to the CIM Object Manager. */ while(e.hasMoreElements()) { CIMInstance ci = cc.getInstance((CIMObjectPath)(e.nextElement ()),true, true, true, null); ci.setProperty("b", new CIMValue(new Integer(10))); cc.setInstance(new CIMObjectPath(),ci); } } ...
A CIM property is a value that describes the characteristic of a CIM class. Properties can be thought of as a pair of functions. One function gets the property value and one function sets the property value.
The following example uses enumerateInstanceNames to return the names of all instances of the Solaris processor. This example uses getProperty to get the value of the current clock speed for each instance, and println to print the current clockspeed values.
... { /* Create an object (CIMObjectPath) to store the name of the Solaris_Processor class. */ CIMObjectPath cop = new CIMObjectPath("Solaris_Processor"); /* The CIM Object Manager returns an enumeration containing the names of instances of the Solaris_Processor class. */ Enumeration e = cc.enumerateInstanceNames(cop); /* Iterate through the enumeration of instance object paths. Use the getProperty method to get the current clockspeed value for each Solaris processor. */ while(e.hasMoreElements()) { CIMValue cv = cc.getProperty(e.nextElement(CIMObjectPath), "CurrentClockSpeed"); System.out.println(cv); } ... }
The following example sets the initial shell value for all Solaris_UserTemplate instances. This code segment uses enumerateInstanceNames to get the names of all instances of the Solaris_User Template. This code segment uses setProperty to set the value of the initial shell for each instance.
... { /* Create an object (CIMObjectPath) to store the name of the Solaris_Processor class. */ CIMObjectPath cop = new CIMObjectPath("Solaris_UserTemplate"); /* The CIM Object Manager returns an enumeration containing the names of instances of the Solaris_UserTemplate class and all its subclasses. */ Enumeration e = cc.enumerateInstanceNames(cop); /* Iterate through the enumeration of instance object paths. Use the setProperty method to set the initial shell value to /usr/bin/sh for each Solaris_UserTemplate instance. */ for (; e.hasMoreElements(); cc.setProperty(e.nextElement(), "/usr/bin/sh", new CIMValue(new Integer(500)))); ... }
An enumeration is a collection of objects that can be retrieved one object at a time. You can enumerate classes, class names, instances, instance names, and namespaces. The results of an enumeration depend on the method and the arguments used, as shown in the following table.
Method |
No args |
deep |
localOnly |
---|---|---|---|
enumerateClasses |
Returns the contents of the class specified in path. |
If true: Returns the contents of the subclasses of the specified class, but does not return the class. |
If true: Returns only noninherited properties and methods of the specified class. |
If false: Returns the contents of the direct subclasses of the specified class. |
If false: Returns all properties of the specified class. |
||
enumerateInstances |
Returns the instances of the class specified in path. |
If true: Returns the instances of the specified class and its subclasseses. |
If true: Returns only noninherited properties of the instances of the specified class. |
If false: Returns the instances of the specified class and its subclasses. The properties of the subclasses are filtered out. |
If false: Returns all properties of the instances of the specified class. |
||
enumerateClassNames |
Returns the names of the class specified in path. |
If true: Returns the names of all classes derived from the specified class. |
N/A |
If false: Returns only the names of the first-level children of the specified class. |
N/A |
||
enumerateInstanceNames |
Returns the names of the instances of the class specified in path. |
N/A |
N/A |
enumNameSpace |
Returns a list of the namespaces within the namespace specified in path |
If true: Returns the entire hierarchy of namespaces under the specified namespace. |
N/A |
If false: Returns only the first level children of the specified namespace. |
N/A |
The following example program returns the contents of a class and its subclasses.
... { /* Creates a CIMObjectPath object and initializes it with the name of the CIM class to be enumerated (myclass). */ CIMObjectPath cop = new CIMObjectPath(myclass); /* This enumeration contains the classes and subclasses in the enumerated class (deep=true). This enumeration returns only the noninherited methods and properties for each class and subclass (localOnly is true).*/ Enumeration e = cc.enumerateClasses(cop, true, true); } ...
The following example program performs a deep and shallow (deep=false) enumeration of classes and instances. The localOnly flag returns the contents of the classes and instances instead of the names of the classes and instances.
import java.rmi.*; import java.util.Enumeration; import javax.wbem.client.CIMClient; import javax.wbem.cim.CIMClass; import javax.wbem.cim.CIMException; import javax.wbem.cim.CIMInstance; import javax.wbem.cim.CIMNameSpace; import javax.wbem.cim.CIMObjectPath; import javax.wbem.client.UserPrincipal; import javax.wbem.client.PasswordCredential; /** * This example enumerates classes and instances. It does deep and * shallow enumerations on a class that is passed from the command line */ public class ClientEnum { public static void main(String args[]) throws CIMException { CIMClient cc = null; CIMObjectPath cop = null; if (args.length < 4) { System.out.println("Usage: ClientEnum host user passwd " + "classname"); System.exit(1); } try { CIMNameSpace cns = new CIMNameSpace(args[0]); UserPrincipal up = new UserPrincipal(args[1]); PasswordCredential pc = new PasswordCredential(args[2]); cc = new CIMClient(cns, up, pc); // Get the class name from the command line cop = new CIMObjectPath(args[3]); // Do a deep enumeration of the class Enumeration e = cc.enumerateClasses(cop, true, true, true, true); // Will print out all the subclasses of the class. while (e.hasMoreElements()) { System.out.println(e.nextElement()); } System.out.println("+++++"); // Do a shallow enumeration of the class e = cc.enumerateClasses(cop, false, true, true, true); // Will print out the first-level subclasses. while (e.hasMoreElements()) { System.out.println(e.nextElement()); } System.out.println("+++++"); // Do a deep enumeration of the instances of the class e = cc.enumerateInstances(cop, false, true, true, true, null); // Will print out all the instances of the class and its // subclasses. while (e.hasMoreElements()) { System.out.println(e.nextElement()); } System.out.println("+++++"); // Do a shallow enumeration of the instances of the class e = cc.enumerateInstances(cop, false, false, true, true, null); // Will print out all the instances of the class. while (e.hasMoreElements()) { System.out.println(e.nextElement()); } System.out.println("+++++"); e = cc.enumerateInstanceNames(cop); while (e.hasMoreElements()) { System.out.println(e.nextElement()); } System.out.println("+++++"); e = cc.enumerateInstanceNames(cop); while (e.hasMoreElements()) { CIMObjectPath opInstance = (CIMObjectPath)e.nextElement(); CIMInstance ci = cc.getInstance(opInstance, false, true, true, null); System.out.println(ci); } System.out.println("+++++"); } catch (Exception e) { System.out.println("Exception: "+e); } // close session. if (cc != null) { cc.close(); } } }
The following example program returns a list of class names and subclass names.
... { /* Creates a CIMObjectPath object and initializes it with the name of the CIM class to be enumerated (myclass). */ CIMObjectPath cop = new CIMObjectPath(myclass); /* This enumeration contains the names of the classes and subclasses in the enumerated class. */ Enumeration e = cc.enumerateClassNames(cop, true); } ...
This example program uses the enumNameSpace method in the CIMClient class to print the name of the namespace and all the namespaces contained within the namespace.
import java.rmi.*; import java.util.Enumeration; import javax.wbem.cim.CIMClass; import javax.wbem.cim.CIMException; import javax.wbem.cim.CIMInstance; import javax.wbem.cim.CIMNameSpace; import javax.wbem.cim.CIMObjectPath; import javax.wbem.client.CIMClient; import javax.wbem.client.PasswordCredential; import javax.wbem.client.UserPrincipal; /** * */ public class EnumNameSpace { public static void main(String args[]) throws CIMException { CIMClient cc = null; // if not four arguments, show usage and exit if (args.length < 4) { System.out.println("Usage: EnumNameSpace host username " + "password namespace"); System.exit(1); } try { // args[0] contains the hostname. We create a CIMNameSpace // (cns) pointing to the specified namespace on the // specified host CIMNameSpace cns = new CIMNameSpace(args[0], ""); // args[1] and args[2] contain the username and password. // We create a UserPrincipal (up) using the username and // a PasswordCredential using the password. UserPrincipal up = new UserPrincipal(args[1]); PasswordCredential pc = new PasswordCredential(args[2]); // Connect to the CIM Object Manager and pass it the // CIMNameSpace, UserPrincipal and PasswordCredential objects // we created. cc = new CIMClient(cns, up, pc); // Use the namespace (args[3]) to create a CIMObjectPath CIMObjectPath cop = new CIMObjectPath("", args[3]); // Enumerate the namespace Enumeration e = cc.enumNameSpace(cop); while (e.hasMoreElements()) { System.out.println((CIMObjectPath)e.nextElement()); } // end while } catch (Exception e) { // is we have an exception, catch it and print it out. System.out.println("Exception: "+ e); } // end catch // close session. if (cc != null) { cc.close(); } } }
An association describes a relationship between two or more managed resources such as a computer and its hard disk. This relationship is abstracted in an association class, which is a special type of class that contains an association qualifier. You can add or change an association class without affecting the actual objects.
The preceding figure shows two classes, Teacher and Student. Both classes are linked by the TeacherStudent association. The TeacherStudent association has two references:
Teaches, a property that refers to an instance of the Teacher class
TaughtBy, a property that refers to an instance of the Student class
The association methods in CIMClient return information about the relationships between classes and instances. These methods are described in the following table.
Table 4–2 Association Methods
Method |
Description |
---|---|
associators |
Gets the CIM classes or instances that are associated with the specified CIM class or instance |
associatorNames |
Gets the names of the CIM classes or instances that are associated with the specified CIM class or instance |
references |
Gets the association classes or instances that refer to the specified CIM class or instance, respectively |
referenceNames |
Gets the names of the association classes or instances that refer to the specified CIM classes or instances, respectively |
These methods take one required argument, CIMObjectPath. CIMObjectPath is the name of a source CIM class or CIM instance whose associations, associated classes, or instances you want to return. If the CIMOM does not find any associations, associated classes, or instances, the CIMOM does not return anything.
If CIMObjectpath is a class, the methods return the associated classes and the subclasses of each associated class.
If CIMObjectpath is an instance, the methods return the instances of the associated class and the subclasses of each associated class.
In the preceding figure, the associators and associatorNames methods return information about the classes associated with the Teacher and Student classes. The references and referenceNames methods return information about the associations between the Teacher and Student classes.
Table 4–3 TeacherStudent Methods
Example |
Output |
Description |
---|---|---|
associators(Teacher, null, null, null, null, false, false, null) |
Student class |
Returns associated classes. Student is linked to Teacher by the TeacherStudentassociation |
associators(MathTeacher, null, null, null, null,,false, false, null) |
Student |
Returns associated classes. Teacher is linked to Student by the TeacherStudent association. MathTeacher and ArtTeacher inherit the TeacherStudent association from Teacher |
associatorNames(Teacher, null, null, null, null) |
Name of the Student class |
Returns the names of the associated classes. Student is linked to Teacher by the TeacherStudent association |
references(Student, null, null. false, false, null) |
TeacherStudent |
Returns the associations in which Student participates |
references(Teacher, null, null. false, false, null) |
TeacherStudent |
Returns the associations in which Teacher participates |
references(Teacher, null, null, false, false, null) |
TeacherStudent |
Returns the associations in which Teacher participates |
referenceNames(Teacher, null, null) |
Name of the TeacherStudent class |
Returns the names of the associations in which Teacher participates |
referenceNames(Teacher, null, null) |
Name of the TeacherStudent class |
Returns the names of the associations in which Teacher participates |
The associatorNames and referenceNames methods do not take the arguments includeQualifiers, includeClassOrigin, and propertyList. These arguments are irrelevant to a method that returns only the names of instances or classes, not their entire contents.
To specify the name of a class, you specify its model path. The model path includes the class's namespace, class name, and keys. A key is a property or set of properties that uniquely identify managed resource. Key properties are marked with the key qualifier. The following example shows a sample model path:
\\myserver\\root\cimv2\Solaris_ComputerSystem.Name= mycomputer: CreationClassName=Solaris_ComputerSystem
This model path specifies the following values:
\\myserver\root\cimv2 is the default CIM namespace on host myserver.
Solaris_ComputerSystem is the name of the class from which the instance is derived.
Name=mycomputer, CreationClassName=Solaris_ComputerSystem are two key properties in the format key property=value.
You use the enumerateInstances method to return all instances of a given class, and a loop structure to iterate through the instances. In the loop, you can pass each instance to an association method.
This example enumerates the instances in the op class and its subclasses. The example uses a while loop to cast each instance to a CIMObjectPath (op), and passes each instance as the first argument to the associators method.
{ ... Enumeration e = cc.enumerateInstances(op, true); while (e.hasMoreElements()) { op = (CIMObjectPath)e.nextElement(); Enumeration e1 = cc.associators(op, null, null, null, null, false, false, null); ... }
You can use the optional arguments with the association methods to filter the classes and instances that are returned. Each optional parameter value passes its results to the next parameter for filtering until all parameters have been processed.
You can pass values for any one or a combination of the optional parameters. You must enter a value or null for each parameter. The first four parameters are used to filter the classes and instances that are returned:
assocClass
resultClass
resultRole
role
You use the invokeMethod interface to call a method in a class supported by a provider. To retrieve the signature of a method, an application must first get the definition of the class to which the method belongs. The invokeMethod method returns a CIMValue. The return value is null when the method that you invoke does not define a return value.
The invokeMethod interface takes four arguments, as described in the following table.
Table 4–4 invokeMethod Parameters
Parameter |
Data Type |
Description |
---|---|---|
name |
CIMObjectPath |
The name of the instance on which the method must be invoked |
methodName |
String |
The name of the method to call |
inParams |
Vector |
Input parameters to pass to the method |
outParams |
Vector |
Output parameters to get from the method |
This example gets the instances of the CIM_Service class, which represent services that manage device or software features. The example uses the invokeMethod method to stop each service.
{ ... /* Pass the CIM Object Path of the CIM_Service class to the CIM Object Manager. We want to invoke a method defined in this class. */ CIMObjectPath op = new CIMObjectPath("CIM_Service"); /* The CIM Object Manager returns an enumeration of instance object paths, the names of instances of the CIM_Service class. */ Enumeration e = cc.enumerateInstanceNames (op, true); /* Iterate through the enumeration of instance object paths */ while(e.hasMoreElements()) { // Get the instance CIMObjectPath op = (CIMObjectPath) e.nextElement(); //Invoke the Stop Service method to stop the CIM services. cc.invokeMethod("StopService", null, null); } }
The getClass method gets a CIM class. When a class is created, the class inherits the methods and properties of all parent classes in the class hierarchy. The getClass method takes the localOnly Boolean argument.
If localOnly is true, getClass returns only noninherited properties and methods.
If localOnly is false, getClass returns all properties in the class.
This example uses the following methods to retrieve a class definition:
CIMNameSpace – Create a new namespace
CIMClient – Create a new client connection to the CIM Object Manager
CIMObjectPath – Create an object path, which is an object to contain the name of the class to retrieve
getClass – Retrieve the class from the CIM Object Manager
import java.rmi.*; import javax.wbem.client.CIMClient; import javax.wbem.cim.CIMInstance; import javax.wbem.cim.CIMValue; import javax.wbem.cim.CIMProperty; import javax.wbem.cim.CIMNameSpace; import javax.wbem.cim.CIMObjectPath; import javax.wbem.cim.CIMClass; import javax.wbem.cim.CIMException; import java.util.Enumeration; /** * Gets the class specified in the command line. Works in the default * namespace root\cimv2. */ public class GetClass { public static void main(String args[]) throws CIMException { CIMClient cc = null; try { CIMNameSpace cns = new CIMNameSpace(args[0]); UserPrincipal up = new UserPrincipal("root"); PasswordCredential pc = new PasswordCredential("root_password"); cc = new CIMClient(cns); CIMObjectPath cop = new CIMObjectPath(args[1]); // Returns only the methods and properties that // are local to the specified class (localOnly is true). cc.getClass(cop, true); } catch (Exception e) { System.out.println("Exception: "+e); } if(cc != null) { cc.close(); } } }
Each CIMClient method throws a CIMException, or error condition. The CIMOM creates a hierarchy of WBEM-specific exceptions by using Java exception handling. The CIMException class is the base class for CIM exceptions. All other CIM exception classes extend from the CIMException class.
Each class of CIM exceptions defines a particular type of error condition that the API code handles. CIMException has methods to retrieve error codes and parameters that relate to the exception. Refer to file:/usr/sadm/lib/wbem/doc/index.html for more information on the CIMException class.
The Solaris operating environment installation compiles the standard CIM Managed Object Format (MOF) files into the default namespaces. If you create a new namespace, you must compile the appropriate CIM .mof files into the new namespace before you create objects in that namespace. For example, if you plan to create classes that use the standard CIM elements, compile the CIM Core Schema into the namespace. If you plan to create classes that extend the CIM Application Schema, compile the CIM Application into the namespace.
This example uses a two-step process to create a namespace within an existing namespace:
When the namespace is created, the CIMNameSpace method constructs a namespace object that contains the parameters to be passed to the CIM Object Manager.
The CIMClient class connects to the CIM Object Manager and passes the namespace object. The CIM Object Manager creates the namespace, using the parameters contained in the namespace object.
{ ... /* Creates a namespace object on the client, which stores parameters passed to it from the command line. args[0] contains the host name (for example, myhost); args[1] contains the parent namespace (for example, the toplevel directory.) */ CIMNameSpace cns = new CIMNameSpace (args[0], args[1]); UserPrincipal up = new UserPrincipal("root"); PasswordCredential pc = new PasswordCredential("root_password"); /* Connects to the CIM Object Manager and passes it three parameters: the namespace object (cns), which contains the host name (args[0]) and parent namespace name (args[1]), a user name string (args[3]), and a password string (args[4]). */ CIMClient cc = new CIMClient (cns, up, pc); /* Passes to the CIM Object Manager another namespace object that contains a null string (host name) and args[2], the name of a child namespace (for example, secondlevel). */ CIMNameSpace cop = new CIMNameSpace("", args[2]); /* Creates a new namespace by the name passed in as args[2] under the toplevel namespace on myhost./* cc.createNameSpace(cop); ... }
Use the deleteNameSpace method to delete a namespace.
You can also create a base class using the MOF language. If you are familiar with MOF syntax, use a text editor to create a MOF file. Then use the MOF compiler to compile the file into Java classes. See Chapter 7, Creating JavaBeans Components Using the MOF Compiler.
Use the CIMClass class to create a Java class representing a CIM class. To declare the most basic class, you need only specify the class name and a key property or an abstract qualifier. However, most classes include properties that describe the data of the class. To declare a property, include the property's data type, name, and an optional default value. The property data type must be an instance of CIMDataType.
A property can have a key qualifier, which identifies the property as a key property. A key property uniquely defines the instances of the class. Only keyed classes can have instances. Therefore, if you do not define a key property in a class, the class can only be used as an abstract class. If you define a key property in a class in a new namespace, you must first compile the core MOF files into the namespace. The core MOF files contain the declarations of the standard CIM qualifiers, such as the key qualifier.
Class definitions can be more complicated, including such features as aliases, qualifiers, and qualifier flavors.
Use the CIMClient mothod, deleteClass, to delete a class. This method removes the class and throws a CIMException.
You must first remove any existing subclasses or instances before deleting a base class.
This example uses the deleteClass method to delete a class in the default namespace root\cimv2. This program takes four required string arguments:
hostname
classname
username
password
import javax.wbem.cim.CIMClass; import javax.wbem.cim.CIMException; import javax.wbem.cim.CIMNameSpace; import javax.wbem.cim.CIMObjectPath; import javax.wbem.client.CIMClient; import javax.wbem.client.UserPrincipal; import javax.wbem.client.PasswordCredential; import java.rmi.*; import java.util.Enumeration; /** * Deletes the class specified in the command line. Works in the default * namespace root/cimv2. */ public class DeleteClass { public static void main(String args[]) throws CIMException { CIMClient cc = null; // if not four arguments, show usage and exit if (args.length != 4) { System.out.println("Usage: DeleteClass host className " + "username password"); System.exit(1); } try { // args[0] contains the hostname. We create a CIMNameSpace // (cns) pointing to the default namespace on the specified host CIMNameSpace cns = new CIMNameSpace(args[0]); // args[2] and args[3] contain the username and password. // We create a UserPrincipal (up) using the username and // a PasswordCredential using the password. UserPrincipal up = new UserPrincipal(args[2]); PasswordCredential pc = new PasswordCredential(args[3]); cc = new CIMClient(cns, up, pc); // Get the class name (args[4]) and create a CIMObjectPath CIMObjectPath cop = new CIMObjectPath(args[1]); // delete the class cc.deleteClass(cop); } catch (Exception e) { System.out.println("Exception: "+e); } if (cc != null) { cc.close(); } } }