I am developing a client server application where i can invoke server from the remote client and the some string is returned from the client. I am using CORBA
. I have a user interface developed by using Java Swing
on Netbeans
. I need to invoke the server when a button is clicked on the client interface. For that I have to put following code segment inside jButton
action listener.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try{
// create and initialize the ORB
ORB orb = ORB.init(args, null);
// get the root naming context
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");
// Use NamingContextExt instead of NamingContext. This is
// part of the Interoperable naming Service.
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
// resolve the Object Reference in Naming
String name = "Hello";
bsImpl = BubbleSortHelper.narrow(ncRef.resolve_str(name));
//System.out.println("Obtained a handle on server object: " + helloImpl);
String z = bsImpl.sort(inputFlArray);
System.out.println(z);
bsImpl.shutdown();
} catch (Exception e) {
System.out.println("ERROR : " + e) ;
e.printStackTrace(System.out);
}
}
Once I compile it, I get the error saying args cannot be identified. I just copied ORB orb = ORB.init(args, null);
code segment from a place where it was inside the main method. I know that error comes up because of I used args outside the main method.
I need to know that how can I initialize ORB
object here outside the main method?