M.S A.B
M.S A.B

Reputation: 1

class not found error in rmic compile

I use rmi class and I have one problem. My interface's name is server and my implementing class's name is serverImpl. When i type rmic -v1.2 -classpath .. serverImpl in command line (after compiling interface and classes) it shows this error:

error: Class serverImpl not found.

I checked that serverImpl exists in the specified directory.

Upvotes: 0

Views: 8226

Answers (3)

Ramzi  Komati
Ramzi Komati

Reputation: 176

  1. Put your server class and the implemented class in a folder, name it x

  2. Add this package on top of each class package x;

  3. Open cmd and write javac x/MyServer.java and javac x/MyImpl.java from the directory that contain the x folder.

  4. Write rmic x.MyServer from the directory that contain the x folder.

  5. You should have now a MyServer_stub.class and you can have a nice day :)

PS: It is important that the package name is different than RMI or any object used inside the class. Otherwise you will have object collision.

Upvotes: 6

Ram Narayan
Ram Narayan

Reputation: 171

Please convert the slashes (/) to dots(.). It worked for me.

I have following structure

rmitest/
rmitest/MyRemoteIf.java
rmitest/MyRemoteImpl.java

javac rmitest/*.java

rmic rmitest.MyRemoteImpl

The output was :

rmitest/MyRemoteIf.class

rmitest/MyRemoteImpl.class

rmitest/MyRemoteImpl_Stub.class

rmitest/MyRemoteImpl_Skel.class

Good Luck!! Karan

Upvotes: -2

user207421
user207421

Reputation: 310840

serverImpl doesn't have to 'exist in the specified directory'. You haven't specified a directory, you have specified a CLASSPATH, and serverImpl has to exist within that, under the appropriate package structure, which you also have to name correctly in the command line. So if serverImpl is in package x.y, you have to specify a CLASSPATH that contains the x/y directory, and specify x.y.serverImpl on the command line. Exactly as you do when running with the 'java' command.

But you haven't needed rmic at all for about eight years - see the class Javadoc for UnicastRemoteObject.

Upvotes: 0

Related Questions