sivaramaiah  
 
  Record 1 11/22/2017 3:34am (UTC)
   
 

Record1:1.Communication:
Create a server that accepts the requests from client and client displays the server system information
---------------------------------------------------------------

1. Interface program                comm.java
-----------------------------------------------------
import java.rmi.*;

public interface comm extends Remote
{
 String showInfo() throws RemoteException;
}

-----------------------------------------------------------------------

Program2: Implementation                   commImp.java
--------------------------------------------------------------------------

import java.rmi.*;
import java.rmi.server.*;
public class commImp extends UnicastRemoteObject implements comm
{
 public commImp(String strInfo) throws RemoteException
 {
  Info = strInfo;
 }
 
 public String showInfo() throws RemoteException
 {
  return "Message from commImp : "+Info;
 }
 private String Info;
 
}

-------------------------------------------------------------------------
 Program 3: Server program              commServer.java
-----------------------------------------------------------------------------

import java.rmi.*;
import java.rmi.server.*;
public class commServer
{
 public static void main(String[] args)
 {
  try
  {
  System.out.print("Constructing Server Implementation...");
  commImp cimp1 = new commImp("This is Developed By Raja");
  commImp cimp2 = new commImp("And it is an RMI Example.");
  System.out.print("Done!nBinding Server Implementation...");
  Naming.rebind("author",cimp1);
  Naming.rebind("about",cimp2);
  System.out.print("Done!nWaiting for Invocations from client...n"); 
  }
  catch(Exception e)
  { System.out.print("nError Generated in commServer : "+e.toString()+"n");
  }
 }
}

-----------------------------------------------------------------------------
Program 4: Client program            commClient.java
---------------------------------------------------------------------------

import java.rmi.*;
import java.rmi.server.*;
import sun.applet.*;
public class commClient
{
 public static void main(String[] args)
 {
 System.setSecurityManager(new RMISecurityManager());
  try
  {
  System.out.print("Naming.lookup for Bindings...");
  comm com1 = (comm) Naming.lookup("author");
  comm com2 = (comm) Naming.lookup("about");
  System.out.print("Done!n");
  System.out.print("Info from author object: "+com1.showInfo()+"n");
  System.out.print("Info from about object: "+com2.showInfo()+"n");
  }
  catch(Exception e)
  { System.out.print("Error Generated in commServer : "+e.toString()+"n");
  }
 System.exit(0);
 }
}

--------------------------------------------------------------------------
Program 5: Show bings class          showBindings.java
-------------------------------------------------------------------------

import java.rmi.*;
import java.rmi.server.*;
public class showBindings
{
 public static void main(String[] args)
 {
  try
  {
   String[] bindings = Naming.list("");
   for(int i=0;i<bindings.length;i++)
   System.out.println("Binding ["+(i+1)+"] => "+bindings[i]);
  }
  catch(Exception e)
  { System.out.println("Error in showBindings : "+e.toString()); }
  
 }
}

------------------------------------------------------------------------
Program 6:   client.policy
----------------------------------------------------------
grant
{
 permission java.net.SocketPermission
 "*:1024-65335","connect";
};

-----------------------------------------------------------------------
How to run the program
________________________________________
1. compile all java files
 javac *.java
2. use RMICompiler to create stubs & skeletons of Implementations
 
 rmic commImp
3. run rmiregistry
 
 start rmiregistry
4. create policy file with following contents
 client.policy
 ~~~~~~~~~~~~~
 
 grant
 {
  permission java.net.SocketPermission
  "*:1024-65335","connect";
 };
5. run server
 java commServer
6. run client with policy created in step 4.
 java -Djava.security.policy=client.policy commClient
 
  Menu Items
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

  add
HOT TOPICS
MCA PROJECT DETAILS ------------------------------------- Jntu all Lab manuals ------------------------------------- Jntu Syllabus Books ------------------------------------- Paper presentations ------------------------------------- Seminars ------------------------------------- Campus Papers ------------------------------------- Competetive Exams GATE ------------------------------------- GRE ------------------------------------- TOEFL ------------------------------------- IELTS ------------------------------------- CAT ------------------------------------- GMAT ------------------------------------- Templates ------------------------------------- Students Resume Preparation tips ------------------------------------- Job zone(Interview questions) ------------------------------------- Google Adsence html code ------------------------------------- Web sites --------x--------------x-----------
  Advertisement
  Advertisement

 


-----------------------------
  Offline Messages
  Adds
  Visitors Information
Today, there have been 67422 visitors (190447 hits) on this page!
=> Do you also want a homepage for free? Then click here! <= --------------------------------------------------