Can't complie .class file with rmic , class not file

3.1k Views Asked by At

Well i decided to create RMI but faced with one problem. i put CLASSPATH= (to my jdk) then i decided to make Stub with rmic. I wrote: 1. rmic -classpath "D:\workspace\Rmi.example\bin\rmi\app" AddServer -d D:\workspace

where i got such message: error: File D:\workspace\Rmi.example\bin\rmi\app\AddServer.class does not contai n type AddServer as expected, but type rmi.app.AddServer. Please remove the file , or make sure it appears in the correct subdirectory of the class path. error: Class AddServer not found. 2 errors

3

There are 3 best solutions below

0
On

You're supposed to run rmic from the base directory where your package starts. For example: rmic -classpath "D:\workspace\Rmi.example\bin\" rmi.app.AddServer -d D:\workspace

0
On
rmic -classpath "D:\workspace\Rmi.example\bin" rmi.app.AddServer -d D:\workspace

BUT: Don't use 'rmic' at all. It hasn't been required for about ten years. Read the preamble to UnicastRemoteObject. Basically, as long as you provide a port number when constructing/exporting your remote objects, even zero, a dynamic stub can be generated instead at runtime.

3
On

I understand your class AppServer is in rmi.app package? Then your classpath must be D:\workspace\Rmi.example\bin, not D:\workspace\Rmi.example\bin\rmi\app