java client in corba problem
hi
i am beaginer in java and I have a problem that can not get rid of more than 2 weeks. I work on the example from the book "Teach Yourself CORBA in 14Days" except that I use a java compiler idlj there used Visibroker. application is called StockMarket. server is ok, but there are problems with the Client Applications. I try to compile I get an error: connect (java.lang.String []) in StockMarket.StockClient can not be applied to (). this is the StockClient.java code:
Code:
import StockMarket.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
public class StockClient {
StockClient() {
}
public void run() {
connect();
if (myStock != null) {
doSomething();
}
}
protected void connect(String [] args) {
try {
ORB orb = ORB.init (args, null);
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService") ;
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
String name = "StockMarket";
myStock = StockHelper.narrow(ncRef.resolve_str(name)) ;
System.out.println("Obtained a handle on server object: " + myStock);
System.out.println("Succesfully bound to a StockServer.");
}
catch (Exception e) {
System.out.println("EROR : " + e) ;
e.printStackTrace(System.out);
}
}
protected void doSomething() {
try{
String [] stockSymbols = myStock.getStockSymbols();
for (int i = 0; i < stockSymbols.length; i++) {
System.out.println(stockSymbols[i] + " " + myStock.getStockValue (stockSymbols[i]));
}
}
catch (org.omg.CORBA.SystemException ex) {
System.err.println("Fatal eror: " + ex);
}
}
public static void main (String args []) {
StockClient stockClient = new StockClient();
stockClient.connect(args) ;
stockClient.run();
while (true);
}
private Stock myStock;
}
and this is StockMarket.idl code
Code:
// StockMarket.idl
// The StockMarket module consists of definitions useful
// for building stock market-related applications.
module StockMarket {
// The StockSymbol type is used for symbols (names)
// representing stocks.
typedef string StockSymbol;
// A StockSymbolList is simply a sequence of
// StockSymbols.
typedef sequence<StockSymbol> StockSymbolList;
// The StockServer interface is the interface for a
// server which provides stock market information.
// (See the comments on the individual methods for
// more information)
interface Stock{
// getStockValue() returns the current value for
// the given StockSymbol. If the given StockSymbol
// is unknown, the results are undefined (this
// would be a good place to raise an exception).
float getStockValue(in StockSymbol symbol);
// getStockSymbols() returns a sequence of all
// StockSymbols known by this StockServer
StockSymbolList getStockSymbols();
};
};
I can post and servers code too if you need, but he work fine.
what I'm doing wrong, can you give me some help? :confused: