I am staring to learn about RMI in java and I am using Netbeans 7.0.1. I created a basic interface
package helloclass;
import java.rmi.*;
public interface HelloInterface extends Remote
{
public String hello() throws RemoteException;
}
This is the class that implements the interface
package helloclass;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
public class HelloClass extends UnicastRemoteObject implements HelloInterface
{
private String message;
public HelloClass() throws RemoteException{}//constructor throwing RemoteException
public String hello() throws RemoteException //method throwing RemoteException
{
return "Saying hello";
}
public static void main(String[] args)
{
}
}
In my understanding I now need to build these two classes and then run the rmic
command in the command prompt.
How do I run this rmic
command in the command prompt using netbeans?.
I have been trying by going to Project Properties and then typing rmic
in the VM options at the Run after specifying the directory where HelloClass.class
is located but it can't seem to find the class.
As of Java 5 there is no need to use the rmic
command for generating stubs, they will be generated dynamically for you, check this
However, if you still want to support clients running on earlier version, run the command from the base directory of the compiled classes (in your case the directory that contains the "helloclass" directory) and use the class qualified name, e.g.: rmic helloclass.HelloClass