0 Replies - 803 Views - Last Post: 22 October 2013 - 01:28 AM

#1 murali2489  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 03-August 13

what parameter needs to be given in Naming.rebind while creating RMI

Posted 22 October 2013 - 01:28 AM

Hi Team,

I have been trying to understand the concept of RMI by writing a simple classes for

1. RMIInterface
2. RMIServer
3. RMI Client

I have written three classes in eclipse and started RMIRegistry by running start rmiregistry command. When i tried to compile RMI server class im getting an error as mentioned below. MY code for RMI server, RMI interface and RMIClient is shown below, Please explain how to get my code to work.

Unknown host: sample.test; nested exception is:
java.net.UnknownHostException: sample.test

package com.rmi.client;

import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

public class RMIServer extends UnicastRemoteObject implements RMIInterface{

	public RMIServer() throws RemoteException {
		try {
			Naming.rebind("//sample.test/RMIServer", this);
		}catch(Exception e){
	public static void main(String[] args) throws RemoteException {
		// TODO Auto-generated method stub

		RMIServer reference = new RMIServer();

	public String query(String request) throws RemoteException {
		// TODO Auto-generated method stub
		return "working";



package com.rmi.client;

public interface RMIInterface extends java.rmi.Remote{

	public String query(String request)throws java.rmi.RemoteException;



package com.rmi.client;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

public class RMIClient {

	public RMIClient() throws MalformedURLException, RemoteException, NotBoundException{
		RMIInterface remoteObject = (RMIInterface)Naming.lookup("//sample.test/RMIServer");
		String reply = remoteObject.query("sample");
	public static void main(String[] args) throws MalformedURLException, RemoteException, NotBoundException {
		// TODO Auto-generated method stub
		RMIClient reference = new RMIClient();



Is This A Good Question/Topic? 0
  • +

Page 1 of 1