开发者

Create jar for java RMI application

So, I made a simple java RMI application in Eclipse using the genady plugin. It works fine in this environment but it would be nice if it could be run outside Eclipse too.

In Eclipse to run it I first start the RMI registry. Then I enable stubs creation for the server. Then I run the server as an RMI application, also I let Eclipse automatically generate the codebase parameter. Finally I run the client also as a RMI application, adding the parameter security policy (just let eclipse create one for me).

So it is pretty simple really.

My project structure is the following: I have 3 separate java projects:

1) rmi common

2) rmi server

3) rmi client

Both the server and client depend on the common project (have it on their build path).

In the common project I have the remote interface description (basically the methods the client can call from server) and also a class, which is used as a parameter for one of the interface methods.

The server is quite simple really.. extends UnicastRemoteObject and implemen开发者_运维百科ts the interface. Just gets the registry and binds itself.

The client is also not very complicated. Sets a security manager (new RMI security manager) and looks up the server. Also it has a user interface class but that is not so important.

So I am wondering how to create executable jars from the client and server. Ideally I would like to start up the registry from the command line, then start the server from the CL and finally also the client the same way.

For some reason eclipse won't let me generate an executable jar for these projects even though they both have a main method. I have tried creating a regular jar but it does not work because it does not find the main class.

I would really appreciate if someone could tell me how to export this project from eclipse so that it could be run from the command line.


It's JARs, not JAR. You'll need one for the client and another for the server. The common interface needs to be in both.

If you have those, you can certainly deploy and run the two anywhere you like.

If Eclipse is getting in the way, dump it. Just create the JARs with the correct manifest files by hand.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜