If you want to launch a RMI servant, as a stand-alone, from a JAR file
you must change your program according to the following steps

a)      skip rmiregistry and create an internal registry thread instead

http://java.sun.com/j2se/1.4.2/docs/api/java/rmi/registry/LocateRegistry.htm
l#createRegistry(int)
        and bind your RMI servant to your internal registry

http://java.sun.com/j2se/1.4.2/docs/api/java/rmi/registry/Registry.html#bind
(java.lang.String,%20java.rmi.Remote)

b)      skip the policy file and register a permissive security manager instead
        http://java.sun.com/j2se/1.4.2/docs/api/java/rmi/RMISecurityManager.html
        subclass RMISecurityManager and implement an empty checkXyz() for each
        thrown SecurityException

c)      if you need dynamic client code loading,
        launch an internal (simple/tiny/limited) http server, which points to a
directory of your class files,
        which should be available for your RMI client
        http://java.sun.com/j2se/1.4.2/docs/guide/rmi/spec/rmi-arch5.html

d)      declare the Main-Class JAR manifest attribute

e)      jar it together using Ant, before messing around with maven

f)      launch it using double-click or java -jar ...

Kind regards,
        Jens Riboe


-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] Behalf Of Geoffrey
Sent: Monday, April 12, 2004 5:59 PM
To: [EMAIL PROTECTED]
Subject: Exectable RMI client and server jar


Hi all,

To run my RMI server I currently have to do this (straight from Sun's RMI
tutorial):

start %JAVA_HOME%\bin\rmiregistry
java -Djava.rmi.server.codebase=file:/. -Djava.rmi.server.hostname=localhost
 -Djava.security.policy=java.policy mypackage.ServerEngine

Is it possible to make a single executable jar configured in a way so the
user only has to open it (java -jar or even a double click in windows)?

- How do I configure Maven to configure the -D parameters in the generated
jar?
- Can I place my java.policy file in my jar? (so configure it as a resource
in maven)
- Can I make it call "start rmiregistry"? This one isn't so important as the
rest, as this problem only occurs on the server and the others also occur on
the client.

Thanks for any and all help,
Geoffrey




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to