EX.
NO: RMI PROGRAM FOR DISPLAYING A TEXT
DATE :
AIM
To Write a RMI program for displaying a text.
ALGORITHM
Step 1 : Create the interface in which declare the methods that is called by client.
Step 2 : Server
Implements the methods which is specified in interface
Register the remote object in which in RMI register in order to accessed by the
client
Step 3 : Client
Get the interface from RMI registry
Invoke the corresponding methods
Step 4 : Display the result.
PROGRAM
Interface
Import [Link].*;
Import interface inter extends Remote
{
Public String show() throws RemoteException
}
Client Program
Import [Link].*;
Public class rmiclient
{
Public static void main(String args[]) throws Exception
{
Inter i=(inter) [Link](rmi://localhost:12345/hai”);
[Link]([Link]()) ;
}
}
Server Program
Import [Link].*;
Import [Link].* ;
Import [Link].* ;
Public class rmiserver 1 extends UnucastRemoteObject implements inter
{
Public rmiserver() throws RemoteException
{
Super();
}
Public String show() throws RemoteException
{
Return “hi”;
}
Public static void main(String args[]) throws Exception
{
Rmiserver s= new rmiserver();
[Link](12333);
[Link](“rmi://localhost:12333/hai”,s);
[Link](“Server is Ready”) ;
}
}
OUTPUT
Command Prompt:
D:rmi>path=D:\bea\jdk1.4.0\bin
D:rmi>javac *.java
D:rmi>rmic rmiserver
D:rmi> java rmiserver
Server is Ready
Command Prompt 2 :
D:rmi>path=D:\bea\jdk1.4.0\bin
D:rmi> java rmiclient
hi
RESULT
Thus the rmi program for displaying a text is created and executed successfully and the
output is verified.
[Link] : RMI PROGRAM FOR ADDITION
DATE : OF ARRAY ELEMENTS
AIM
To write a Java RMI program for addition of array elements.
ALGORITHM
Step 1 : Create the interface in which declare the methods that is called by client.
Step 2 : Server
Implements the methods which is specified in interface
Register the remote object in which in RMI register in order to accessed by the
client
Step 3 : Client
Get the interface from RMI registry
Invoke the corresponding methods
Using the arguments the numbers are got.
Step 4 : Display the result.
PROGRAM
Interface
Import interface inter extends Remote
{
Public int add(int a, int b ) throws RemoteException
}
Client Program
Import [Link].*;
Public class rmiclient1
{
Public static void main(String args[]) throws Exception
{
Inter i=(inter) [Link](rmi://localhost:12345”);
Int a = [Link](args[0);
Int b = [Link](args[0);
[Link]([Link](a,b)) ;
}}
Server Program
Import [Link].*;
Import [Link].* ;
Import [Link].* ;
Public class rmiserver 1 extends UnucastRemoteObject implements inter
{
Public rmiserver1() throws RemoteException
{
Super();
}
Public int add (int a, int b ) throws RemoteException
{
Return a+b;
}
Public static void main(String args[]) throws Exception
{
Rmiserver1 s= new rmiserver1();
[Link](12333);
[Link](“rmi://localhost:12333”,s);
[Link](“Server is Ready”) ;
}}
OUTPUT
Command Prompt:
D:rmi>path=D:\bea\jdk1.4.0\bin
D:rmi>javac *.java
D:rmi>rmic rmiserver1
D:rmi> java rmiserver1
Server is Ready
Command Prompt 2 :
D:rmi>path=D:\bea\jdk1.4.0\bin
D:rmi> java rmiclient1 22 14
36
RESULT
Thus the rmi program for adding the array elements is created and executed suceessfully
and the output is verified.
[Link]: ACTIVEX DLL - TO REVERSE A STRING
DATE:
AIM
To write a program for ActiveX Dll that reverses a string.
ALGORITHM
DLL
[Link] MS Visual studio6.0 and create a new active DLL file.
[Link] tools select add procedure.
[Link] class name,enable function and access modifiers as public.
[Link] project and select properties give a name for project and save.
[Link] the coding for class.
[Link] all the file and goto file and select make file dll.
VB
[Link] the visual studio.
[Link] new standard exe file.
[Link] form.
[Link] the coding.
[Link] project reference and add the dll file.
[Link] the program.
CODING
VB
Private sub Command1_click()
Dim s as class1
Set s=new class1
End sub
DLL
Public function Reverse(ByRef str As String)
Reverse=strreverse(str)
End sub
OUTPUT
RESULT
Thus the program for ActiveX Dll to reverse a string is created and executed
successfully and the output is verified.
[Link]: ACTIVEX DLL
DATE: MAXIMUM AND MINIMUM OF THREE NUMBERS
AIM
To write a program to create ActiveX DLL that finds maximum and minimum of 3
numbers.
ALGORITHM
ActiveX DLL
[Link] start and select VB6.0 with ActiveX DLL.
[Link] tools->Add procedure->give function name as max() and min() and edit coding.
[Link] project menu->project1 properties and give project name and project description.
[Link] project.
[Link] [Link] through file menu.
VB
[Link] start and select Vb6.0 with standard EXE.
[Link] form with 3 labels,3 textboxes and 2 command boxes.
[Link] project->References->select Component created in previous [Link] ok
[Link] the program.
CODING
DLL
Public Function max(ByRef a As Integer, b As Integer, c As Integer)
If a > b Then
If a > c Then
MsgBox "maxval" & a
Else: MsgBox "maxval" & c
End If
If b > c Then
MsgBox "maxval" & b
Else
MsgBox "maxval" & c
End If
End If
End Function
Public Function min(ByRef a As Integer, b As Integer, c As Integer)
If a < b Then
If a < c Then
MsgBox "minval" & a
Else: MsgBox "minval" & c
End If
Else
If b < c Then
MsgBox "minval" & b
Else
MsgBox "minval" & c
End If
End If
End Function
VB
Private Sub Command1_Click()
Dim i As class1
Set i = New class1
Max = [Link](Text1, Text2, Text3)
End Sub
Private Sub Command2_Click()
Dim i As class1
Set i = New class1
Min = [Link](Text1, Text2, Text3)
End Sub
OUTPUT
RESULT
Thus the program for ActiveX Dll that finds the maximum and minimum of three
numbers is created and executed successfully and the output is verified.