未找到 rmic 错误类 [英] rmic error class not found
问题描述
我正在阅读 java,我将尝试展示如何使用 RMI 的现成烘焙代码.这些是类:
I'm reading head first java and I'm about to try the ready baked codes that shows how to use RMI. These are the classes:
远程接口
import java.rmi.*;
public interface MyRemote extends Remote {
public String sayHello() throws RemoteException;
}
远程实现
import java.rmi.*;
import java.rmi.server.*;
public class MyRemoteImpl extends UnicastRemoteObject implements MyRemote {
public String sayHello() {
return "Server Says,Hello";
}
public MyRemoteImpl() throws RemoteException { }
public static void main(String[] args) {
try {
MyRemote service = new MyRemoteImpl();
Naming.rebind("Remote Hello", service);
} catch(Exception e) {
e.printStackTrace();
}
}
}
然后我将 .java 和 .class 文件放在 c:\RMI 中.运行它时,它说找不到 MyRemoteImpl 类,即使我从同一目录运行.我怎样才能解决这个问题?谢谢.
Then I placed the .java and the .class file in c:\RMI. When running it, it says MyRemoteImpl class not found even though I'm running from the same directory. How can i fix this? Thanks.
当我尝试运行此命令时出现错误
The error appear when I try to run this command
rmic MyRemoteImpl
推荐答案
BuddingProgrammer 的评论也对我有用.
The comments of BuddingProgrammer worked for my as well.
例如,如果您的类位于文件夹 C:\users\renato\workspace\ADI\src\semana5 中,您应该转到上一层:C:\users\renato\workspace\ADI\src 你应该这样编译:javac semana5\Calculadora.java
For instance if your classes are in folder C:\users\renato\workspace\ADI\src\semana5 you should go to one level above: C:\users\renato\workspace\ADI\src and you should compile like this: javac semana5\Calculadora.java
要运行 RMI,您应该在 C:\users\renato\workspace\ADI\src
中键入以下命令:
To run RMI you should type the following command in C:\users\renato\workspace\ADI\src
:
rmic semana5.CalculadoraImp
这篇关于未找到 rmic 错误类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!