jeffrey o 0 Newbie Poster

when i compiple this using rmiregistry, javac for HelloServer2 and HelloClient it says:

I've attached all files as well

java.rmi.NotBoundException: ReceiveMessageInterface
<<No stacktrace available>>

import java.rmi.*;

import java.rmi.registry.*;

import java.rmi.server.*;

import java.net.*;
import java.util.Random;

public class HelloServer2 extends java.rmi.server.UnicastRemoteObject implements ReceiveMessageInterface
{
	String address;

	Registry registry; 

	int a[]=new int[6];
static boolean flag=true;
 Random diceRoller = new Random();
  int RandomNumber;
boolean flagresults =false;

public int RandomGen()throws RemoteException
{	
       RandomNumber = diceRoller.nextInt(3) + 1;
 	System.out.println("this is roll: "+RandomNumber);
	return RandomNumber;
}

public void check(int y[]) throws RemoteException{

for(int i =0;i<y.length;i++)
{
if(y[i]>50||y[i]<1)
{
System.out.println("you entered a number greater than 50 or less than 1");
flag = false;
break;
}//end of if

if(flag==false)
{
System.out.println("");
break;
}
}//end of for
RandomGen();
	}//end of check

public boolean Results(int y[],boolean flagresults)throws RemoteException
{
    for(int i=0;i<y.length;i++)
    {
    if(RandomNumber==y[i])
    {
        System.out.println("The number you picked "+ y[i]+" is found CONGRATS YOU HAVE WON");
        flagresults = true;
	break;
    }
    if(i==6&&y[i]!=RandomNumber)
    {
        System.out.println("None of the numbers you picked were found SORRY BUT You LOST");
        flagresults=false;
	break;
    }
        }//end of for

return flagresults;
}//end of results

public HelloServer2 () throws RemoteException{

		try{  

			address = (InetAddress.getLocalHost()).toString();
				//address ="localhost";

		}

		catch(Exception e){

			System.out.println("can't get inet address.");

		}

		int port=3232; 

		System.out.println("this address=" + address +  ",port=" + port);

		try{

			registry = LocateRegistry.createRegistry(port);

			registry.rebind("rmiServer", this);

		}

		catch(RemoteException e){

			System.out.println("remote exception"+ e);

		}

	}

	

	static public void main(String args[]){

		
			try{

			HelloServer2 server = new HelloServer2();

			
			}

		catch (Exception e){

			e.printStackTrace();

			System.exit(1);

		}

	}//end ofmain 



}
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.rmi.*;
import java.rmi.registry.*;
import java.net.*;
import java.util.Random;

class HelloClient {

static int[] numberselected = new int[6];
static int i=0;
static String temp;
static boolean flag4loop = true;
//static DataInputStream in = new DataInputStream(System.in);
//static BufferedReader d = new BufferedReader(new InputStreamReader(System.in));
static int roll =0;
static Random diceRoller = new Random();
static InputStreamReader ini=new InputStreamReader(System.in);
static BufferedReader in= new BufferedReader(new InputStreamReader(System.in));

static boolean flagresults;

//public HelloClient() throws RemoteException {}

public static void main(String[] args) throws IOException
    {
		ReceiveMessageInterface rmiServer;
		Registry registry;
		String serverAddress="localhost";
		String serverPort="3232";
		String text="blahblah";
		int y=11;

//roll = diceRoller.nextInt(3) + 1;
//  System.out.println("this is roll: "+roll);


while(i<6 && flag4loop==true && i<numberselected.length)
{
        System.out.print("Please enter the number "+ (i+1) +" of the lotto numbers: ");

        temp=in.readLine();
        //numberselected[x]=in.readInt();

        numberselected[i]=Integer.parseInt(temp);
        System.out.print('\n');
        /*if((numberselected[i])>50||(numberselected[i])<1)//check for invalid number entered
        {
        System.out.print("ERROR: you entered number greater than 50 or less than 1");
        flag4loop=false;
        break;
        }  //end of if*/

        if(i==6)
        {
            flag4loop=false;
            break;
        }
        else i++;
}//while loop ends

        try {
            Remote hishello = Naming.lookup("rmi://localhost/ReceiveMessageInterface");

            ReceiveMessageInterface h = (ReceiveMessageInterface) hishello;

	   registry=LocateRegistry.getRegistry(serverAddress,(new Integer(serverPort)).intValue());
	   rmiServer=(ReceiveMessageInterface)(registry.lookup("rmiServer"));
			// call the remote method
	   	   	   	   
		rmiServer.check(numberselected);
		flagresults=rmiServer.Results(numberselected,flagresults);
		
		if(flagresults==true)
		{			
			System.out.println("CONGRATULATIONS YOUVE WON !!!!!");
		}
		else if(flagresults==false)
		{			
			System.out.println("UNFORTUNATELY YOU'VE LOST FOOL !!!!");
		}
	
           //System.out.println("Server said: " + h.sayHello());
	

        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}
import java.rmi.*;

public interface ReceiveMessageInterface extends Remote
{
  
 void check(int y[]) throws RemoteException;	
 int RandomGen() throws RemoteException;	
 boolean Results(int y[],boolean flagresults) throws RemoteException;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.