old problem

so,i can not solve this problem :

i have wrote a eseay RMI API:

import java.rmi.*;

public interface Calculator extends Remote{

public int addNum(int x,int y) throws RemoteException;

}

import java.rmi.*;

import java.rmi.server.UnicastRemoteObject;

public class CalculatorImpl implements Calculator{

/*public CalculatorImpl() throws RemoteException{

UnicastRemoteObject.exportObject(this);

}*/

public int addNum(int x,int y) throws RemoteException{

System.out.println("Client request to calculate...");

return x+y;

}

}

then my Server :

//import java.rmi.server.*;

import java.rmi.*;

import java.rmi.server.UnicastRemoteObject;

//import java.rmi.registry.*;

public class CalculatorServer {

public static void main(String[]args){

try{

CalculatorImpl c=new CalculatorImpl();

System.out.println("exporting Calculator ...");

Calculator cal=(Calculator) UnicastRemoteObject.exportObject(c);

//Registry registry=LocateRegistry.getRegistry();

Naming.rebind("http://localhost:1099/MyCalculator",cal);

System.out.println("Register Calculator");

}catch(Exception e){

e.printStackTrace();

e.toString();

}

}

}

and my Client :

import java.rmi.*;

public class CalculatorClient {

public static void main(String[]args){

try{

System.out.println("Finding object ...");

Calculator c=(Calculator)Naming.lookup("rmi://localhost/MyCalculator");

if(c.equals(null))

System.out.println("Object not found");

System.out.println(c.addNum(12, 3));

}catch(Exception e){

e.printStackTrace();

e.toString();

}

}

}

then , i got CalculatorImpl_Stub and CalculatorImpl_Skel class but when i try calling java CalculatorServer it is always errors :

java.net.MalformedURLException: invalid URL scheme : http://localhost:1099/MyCalculator

at java.rmi.Naming.parseURL(Unknown Source)

at java.rmi.Naming.rebind(Unknown Source)

at CalculatorServer.main(CalculatorServer.java:12)

need helps,thanks

[2205 byte] By [cuongdeutsch2@yahoo.coma] at [2007-11-27 6:59:12]
# 1
> Naming.rebind(" http://localhost:1099/MyCalculator",cal); Naming.rebind("rmi://localhost:1099/MyCalculator",cal);
ejpa at 2007-7-12 18:49:46 > top of Java-index,Core,Core APIs...
# 2
it doesn't work,i have tried...
cuongdeutsch2@yahoo.coma at 2007-7-12 18:49:46 > top of Java-index,Core,Core APIs...
# 3

i got it,first http://localhost ... is stupid it must be : rmi://localhost/objectname

and when you compile ,you should write : -Djava.rmi.server.codebase=file:/C:/yourdirectory ,so that java knows where is your .class (Stub class )(i think it is helpful when you problem with your CLASSPATH)

cuongdeutsch2@yahoo.coma at 2007-7-12 18:49:46 > top of Java-index,Core,Core APIs...
# 4
When you compile, setting that property has no effect whatsoever. Did you mean when you execute? and if so how is the remote registry or client going to understand a local file: URL?
ejpa at 2007-7-12 18:49:46 > top of Java-index,Core,Core APIs...