Java CORBA入门

今夜我最冷

今夜我最冷

2016-02-19 12:46

关注图老师设计创意栏目可以让大家能更好的了解电脑,知道有关于电脑的更多有趣教程,今天给大家分享Java CORBA入门教程,希望对大家能有一点小小的帮助。

  Below is a simple example of a CORBA program
  download the source file 
  
  b1. prodUCe a idl file like this/b
     hello.idl
     module HelloApp {
       interface Hello    {         
           string sayHello();
      };
    };
  
  b2. produce stub and skeleton files through idltoJava.exe/b
     idltojava hello.idl
     idltojava is now named as idlj.exe and is included in the JDK. 
  
  b3. write a server program like this /b
  
  // HelloServer.java 
    
  import HelloApp.*;
  
  import org.omg.CosNaming.*;
  import org.omg.CosNaming.NamingContextPackage.*;
  import org.omg.CORBA.*;
  
  import java.io.*;
  class HelloServant extends _HelloImplBase 
  {
      public String sayHello()
      {
         return "Hello world !!"; 
      }   
    
  }
  
  public class HelloServer {
  
      public static void main(String args[])
      {
  try{
      // create and initialize the ORB
      ORB orb = ORB.init(args, null);
  
      // create servant and register it with the ORB
      HelloServant helloRef = new HelloServant();
      orb.connect(helloRef);
  
      // get the root naming context
      org.omg.CORBA.Object objRef = 
  orb.resolve_initial_references("NameService");
      NamingContext ncRef = NamingContextHelper.narrow(objRef);
  
      // bind the Object Reference in Naming
      NameComponent nc = new NameComponent("Hello", "");
展开更多 50%)
分享

猜你喜欢

Java CORBA入门

编程语言 网络编程
Java CORBA入门

CORBA 与Java 的结合使用

编程语言 网络编程
CORBA 与Java 的结合使用

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

CORBA与Java的结合使用

编程语言 网络编程
CORBA与Java的结合使用

java入门之:java概述

编程语言 网络编程
java入门之:java概述

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

Java入门(13) More Java!

编程语言 网络编程
Java入门(13) More Java!

规则与自由:为何选择CORBA和Java技术

编程语言 网络编程
规则与自由:为何选择CORBA和Java技术

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

Struts入门经验

Struts入门经验

win10正式版右下角的操作中心图标不见该怎么办?

win10正式版右下角的操作中心图标不见该怎么办?
下拉加载更多内容 ↓