...
public interface Greetings extends Remote
{
String hello( String name) throws RemoteException;
}
|
...
public class GreetingsImpl extends PortableRemoteObject implements Greetings
{
...
public String hello( String name ) throws RemoteException
{
System.out.println("Greeting from" + name);
return "Greetings to " + name;
}
}
|
GreetingsImpl oGreetingsImpl = new GreetingsImpl(); |
Context initialNamingContext = new InitialContext(); |
initialNamingContext.rebind("HelloJavaServer", oGreetingsImpl);
|
> mkdir classes
> javac -classpath . -d classes Server.java
> rmic -iiop -classpath .\classes -d classes Hello.GreetingsImpl
> cd classes
> jar cvf ..\Server.jar .
> cd ..
|



J2eeQuickConfig qc = new J2eeQuickConfig(ApplicationServer.SUN_JDK_RMI_IIOP);
// Default Java version 1.4.2. Options are JDK_131, JDK_141, JDK_142 and JDK_150
// qc.SetTargetJavaVersion(JavaVersion.JDK_150);
// Turn on log with name Log.txt and without appending exist log file
qc.SetApplicationLog(OrbErrorLevel.ERRORS, "CltLog.txt", false);
|
J2eeEasyContext.Init(qc);
// get the server object reference
Hello.Greetings oGreetings = (Hello.Greetings)J2eeEasyContext.Lookup("HelloJavaServer", "Hello.Greetings");
|
string strRet = oGreetings.hello("Ics");
System.Console.WriteLine("{0}", strRet);
|
> start orbd -ORBInitialPort 10050
|
(could also use startNameService.bat located in the DemoJava directory to quick start the name service)
b.) Start the java server by using JNDI CosNaming and work with a name service running on 'localhost' at port '10050':
> start java -cp .;Server.jar -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory -Djava.naming.provider.url=iiop://localhost:10050 Server
|
(could also use buildServer.bat and startServer.bat located in the JavaServer directory to quick build and run the Java Server)
c.) Start the .NET Client.