您现在的位置:软界网技术中心软件开发Java > 技术显示
JBuilder CORBA Applet实做
2005-4-8 0:00:00   网友评论       阅读次数 点此评论
   很多朋友在使用JBuilder来做CORBA Applet的时候,会遇到不少困难。下面是一个教程,不懂的朋友可以照着做一遍,因为能成功,就不会失去信心。然后可以自己再摸一摸。本文中的有些做法不是必须的(甚至是多余的),有些则非此不可。读者可以自己多琢磨琢磨,慢慢也就懂了。

· 准备工作:
软件
JB4E,JDK1.2,jre-1_2_2_005-win.exe(PlugIn1.2.2_005),Win2000P,IE5

· 安装及设置
JDK1.2
JB4E及所带的AppServer4.1,并确保已经能做CORBA程序了(JB IDE配置正确)
用RegSvr32/u …beans.ocx卸掉已有的PlugIn,以防干扰。beans.ocx文件所在的目录可用regedit来在注册表中查看。

开始:

· 1.New一个Project并设置你的Project的JDK指向1.2

· 2.书写以下IDL

module Module1 {
interface Interface1 {
long operation1();
};
};

· 3.生成Server并实现。这里让实现代码如下:

public int operation1() {
ServerMonitor.log('(' + _name + ')Interface1Impl.Java operation1()');
return (int)System.currentTimeMillis();
}

粗体字为所输入代码

· 4.生成一个Applet,加一个jButton和一个jLabel并让局部代码如下:

public class Applet1 extends JApplet {
private untitled1.Module1.Interface1 _interface1;
String _name = 'Interface1';
/**Initialize the applet*/
public void init() {
try {
jbInit();
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(this, null);
_interface1 = untitled1.Module1.Interface1Helper.bind(orb, '/' + _name + '_poa', _name.getBytes());

void jButton1_actionPerformed(ActionEvent e) {
jLabel1.setText(new Integer(_interface1.operation1()).toString());
}

· 5.编译并打包

· 6.用以下命令启动AppServer
ias ?javahome c:jbuilder4jdk1.3

· 7.在IDE中启动Server

· 8.启动一个dos command窗口,进入以下目录
cd inpriseappserverhtmlpublic_html

· 9.拷贝以下文件到该目录下

untitled1.jar
VBjorb.jar
Applet1.html
jre-1_2_2_005-win.exe

· 10.修改Applet1.html为Applet2.html,如下

<HTML>
<HEAD>
<TITLE>
HTML Test Page
</TITLE>
</HEAD>
<BODY>
untitled1.Applet1 will appear below in a Java enabled browser.<BR>
<APPLET
CODEBASE = '.'
archive='vbjorb.jar , untitled1.jar'
CODE = 'untitled1.Applet1.class'
NAME = 'TestApplet'
WIDTH = 400
HEIGHT = 300
HSPACE = 0
VSPACE = 0
ALIGN = middle
>
<PARAM NAME='org.omg.CORBA.ORBClass' VALUE='com.inprise.vbroker.orb.ORB'>
<PARAM NAME='vbroker.orb.alwaysTunnel' VALUE='true'>
<PARAM NAME='vbroker.orb.gatekeeper.ior' VALUE=''>
</APPLET>
</BODY>
</HTML>

· 11.修改Applet1.html为Applet3.html,如下

<HTML>
<HEAD>
<TITLE>
HTML Test Page
</TITLE>
</HEAD>
<BODY>
untitled1.Applet1 will appear below in a Java enabled browser.<BR>
<OBJECT classid='clsid:8AD9C840-044E-11D1-B3E9-00805F499D93'
WIDTH = 400
HEIGHT = 300
NAME = 'TestApplet'
ALIGN = middle
VSPACE = 0
HSPACE = 0
codebase='http://127.0.0.1:8080/jre-1_2_2_005-win.exe#Version=1,2,2,0'>
<PARAM NAME = CODE VALUE = 'untitled1.Applet1.class' >
<PARAM NAME = CODEBASE VALUE = '.' >
<PARAM NAME = ARCHIVE VALUE ='Untitled1.jar , vbjorb.jar' >
<PARAM NAME = NAME VALUE = 'TestApplet' >
<PARAM NAME='org.omg.CORBA.ORBClass' VALUE='com.inprise.vbroker.orb.ORB'>
<PARAM NAME='vbroker.orb.alwaysTunnel' VALUE='true'>
<PARAM NAME='vbroker.orb.gatekeeper.ior' VALUE=''>
</BODY>
</HTML>

粗体字(IP地址)可以为13步中所显示的值

· 12.在该目录下执行
start gatekeeper

· 13.执行以下程序,记下其中的IP地址
printior gatekeeper.ior

· 14.执行以下程序观察运行结果
jdk1.2binappletviewer http:/…:8080/Applet2.html

其中URL主机地址为上一步所看到的IP地址

· 15.在IE5中输入以下URL,观察运行结果

http://…:8080/Applet3.html
其中URL主机地址为13步中所看到的IP地址

怎么样?是不是看到太阳升起来了?  
      来源: 作者:
 
【评论查看】
更多关于 JBuilder CORBA Applet实做  的技术