Getting Started with Java IDL: Running the Hello World Application
Getting Started with Java IDL: Running the Hello World Application
This topic
walks you through running the server and client program that together make up the "Hello World" application or applet.
Running the Hello World Application
Despite its simple design, the Hello World program lets you learn and
experiment with all the tasks required to develop almost any CORBA program
that uses static invocation. To run this client-server application on your development machine:
Start the Java IDL Name Server. To do this from a UNIX command shell, enter:
tnameserv -ORBInitialPort nameserverport
From an MS-DOS system prompt (Windows), enter:
start tnameserv -ORBInitialPort nameserverport
Note that nameserverport is the port on which you want the name server to run.
If you do not specify this, port 900 will be chosen by default. Also note that using Solaris software, you must become root to start a process on a port under 1024. For this reason, we recommend that you use a port number greater than or equal to 1024.
From a second prompt or shell, start the Hello server:
Note that nameserverhost is the host on which the IDL name server is running. You can omit -ORBInitialHostnameserverhost if the name server is running on the same host as the Hello server. You can leave out -ORBInitialPortnameserverport if the name server is running on the default port.
From a third prompt or shell, run the Hello application client:
Note that nameserverhost is the host on which the IDL name server is running. You can omit -ORBInitialHostnameserverhost if the name server is running on the same host as the Hello client. You can leave out -ORBInitialPortnameserverport if the name server is running on the default port.
The client prints the string from the server to the command line:
Hello world!!
The name server and the Hello World server, like many CORBA servers,
run until you explicitly
stop them. To avoid having many servers running, kill the server processes
after the client application returns successfully.
Running the Hello World Applet
You can run the applet from either a Java-enabled Web browser or from the Applet Viewer. In either case, you must run the Name Server and the HelloServer prior to invoking the applet. To run the applet,
From an MS-DOS system prompt (Windows) or command shell (UNIX), start the Java IDL name server:
tnameserv -ORBInitialPort 1050 &
In this example, the nameserverport, which is the port on which you want the name server to run, is set to 1050.
If you do not specify this, port 900 will be chosen by default. Also note that using Solaris software, you must become root to start a process on a port under 1024. For this reason, we recommend that you use a port number greater than or equal to 1024.
From a second prompt or shell, start the Hello server:
Note that nameserverhost is the host on which the IDL name server is running. You can omit -ORBInitialHostnameserverhost if the name server is running on the same host as the Hello server. In this example, the ORBInitialPort, which is the port on which you want the name server to run, is set to 1050.
If you do not specify this, port 900 will be chosen by default. Also note that using Solaris software, you must become root to start a process on a port under 1024. For this reason, we recommend that you use a port number greater than or equal to 1024.
Run the applet.
To run the applet from the appletviewer,
Open another prompt or shell.
Change to the applet directory, Hello.
Start the appletviewer and
browse Tutorial.html by typing:
appletviewer Tutorial.html
Hello world!! prints to the appletviewer frame.
To run the applet from a Web browser,
Open the Web browser.
Open the file Tutorial.html.
Hello world!! prints in the browser frame.
If the applet does not run in the Web browser, make sure you have the Java 2 Runtime Environment, Standard Edition, version 1.3.0, which includes the Java Plugin 1.3. This plugin is needed to run the applet and may not be present in older Web browsers.
The name server and the Hello World server, like many CORBA servers,
run until you explicitly
stop them. To avoid having many servers running, kill the server processes
after the client application returns successfully.
Make sure you have the Java 2 Runtime Environment, Standard Edition, version 1.3.0, which includes the Java Plugin 1.3. This plugin is needed to run the applet and may not be present in older Web browsers. It can be downloaded from http://java.sun.com/products/plugin/index.html.
Specifying ORB Initial Port
The default ORB Initial Port is port 900. If you prefer, you can omit the port specifications if you start the name server on port 900. Using Solaris software, you must become root to start a process on a port under 1024. Remember to exit from root access before continuing with the tutorial if you choose this port for your name server.