Sunteți pe pagina 1din 16

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 jave.rmi.*;
Import interface inter extends Remote
{
Public String show() throws RemoteException
}

Client Program

Import java.rmi.*;
Public class rmiclient
{
Public static void main(String args[]) throws Exception
{
Inter i=(inter) Naming.lookup(rmi://localhost:12345/hai”);
System.out.println(i.show()) ;
}
}

Server Program

Import java.rmi.*;
Import java.rmi.server.* ;
Import java.rmi.registry.* ;
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();
LocateRegistry.createRegistry(12333);
Naming.bind(“rmi://localhost:12333/hai”,s);
System.out.println(“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.
EX.NO : 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 java.rmi.*;
Public class rmiclient1
{
Public static void main(String args[]) throws Exception
{
Inter i=(inter) Naming.lookup(rmi://localhost:12345”);
Int a = Interger.parseInt(args[0);
Int b = Interger.parseInt(args[0);
System.out.println(i.add(a,b)) ;
}}

Server Program

Import java.rmi.*;
Import java.rmi.server.* ;
Import java.rmi.registry.* ;
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();
LocateRegistry.createRegistry(12333);
Naming.bind(“rmi://localhost:12333”,s);
System.out.println(“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.
EX.NO: ACTIVEX DLL - TO REVERSE A STRING
DATE:

AIM
To write a program for ActiveX Dll that reverses a string.

ALGORITHM

DLL

1.start MS Visual studio6.0 and create a new active DLL file.


2.Goto tools select add procedure.
3.Give class name,enable function and access modifiers as public.
4.Goto project and select properties give a name for project and save.
5.type the coding for class.
6.save all the file and goto file and select make file dll.

VB

1.start the visual studio.


2.create new standard exe file.
3.display form.
4.type the coding.
5.Goto project reference and add the dll file.
6.Execute 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.
EX.NO: 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
1.Goto start and select VB6.0 with ActiveX DLL.
2.Goto tools->Add procedure->give function name as max() and min() and edit coding.
3.Goto project menu->project1 properties and give project name and project description.
4.Save project.
5.Make project.dll through file menu.

VB

1.Goto start and select Vb6.0 with standard EXE.


2.Design form with 3 labels,3 textboxes and 2 command boxes.
3.Goto project->References->select Component created in previous project.give ok
4.Run 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 = i.Max(Text1, Text2, Text3)
End Sub

Private Sub Command2_Click()


Dim i As class1
Set i = New class1
Min = i.Min(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.

S-ar putea să vă placă și