javac 不为 RMI 创建存根
我正在为一个大学项目寻找 RMI,但遇到了一些问题。根据我的阅读,java 版本 5 及更高版本应该自动生成必要的存根文件(据我所知,之前需要一个额外的步骤)。
但是,在遵循本教程之后 http:// /download.oracle.com/javase/6/docs/technotes/guides/rmi/hello/hello-world.html 并使用 Javac 编译我的类,我只得到了标准类文件,没有我的存根的迹象文件。
当我尝试运行我的项目时,这得到了证实,我的应用程序崩溃,说它找不到任何存根文件。我错过了什么吗?
注意,运行 java -version
给了我这个:
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) 64-Bit Server VM (build 17.0-b17, mixed mode)
Im looking into RMI for a university project, and ive run into a bit of a problem. From what ive read, java version 5 and up should generate the necessary stub files automatically (as i understand there was previously an additional step required).
However after following this tutorial here http://download.oracle.com/javase/6/docs/technotes/guides/rmi/hello/hello-world.html and compiling my classes with Javac, ive only got the standard class files, no sign of my stub files.
This is confirmed when i try and run my project, my application crashes saying that it cant find any stub files. Am i missing something?
NB, running java -version
gives me this:
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) 64-Bit Server VM (build 17.0-b17, mixed mode)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用了类似的东西
我相信您在服务器中
,而不是注意
exportObject()
的两个参数 - 第二个版本返回不同的类型。这确实对我来说很重要。I believe you used something like
in your server, instead of
Note two arguments to
exportObject()
-- second version returns different type. It indeed make difference for me.>= 5.0 jvm 上不需要或生成存根。
可能有些路径是错误的,教程对于如何设置目录/路径以及从哪里运行东西不是很清楚。
以下内容对我有用:
这里重要的部分是构建和运行内容时您所处的目录,以及将正确的目录传递给类路径和-Djava.rmi.server.codebase。
stubs arn't needed or generated on >= 5.0 jvms.
It might be that some of the paths are wrong, the tutorial isn't very clear on all how to set up the directories/paths and where you run stuff from.
The following worked for me:
The important part here is which directory you stand in when building and running stuff, as well as passing the proper directories to classpath and -Djava.rmi.server.codebase.