This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am having some problems launching my server application due to the location of the codebase file. Basically, my application is launched and packaged using a single .jar file named runme.jar. When this is run using the java -jar command with the parameter "server", it launches the server.
I am trying to set the JVM parameters such as java.security.policy programmatically. I have succcessfully been able to do this for java.security.policy and java.rmi.server.hostname. However, when I try to do this for java.rmi.server.codebase, I am having some issues.
Basically, if I specify the absolute directory of the runme.jar file, using the command:
I receive the error message "java.lang.ClassNotFoundException: suncertify.server.RemoteData_Stub".
I have attempted to retrieve the classpath by printing the command System.getProperty("java.class.path"). When I do this, it only prints runme.jar. I am not sure if this is normal or not but attempting to add additional class paths by adding Class-Path entries to the manifest file does not result in any new paths being displayed.
I am just wondering if someone can help me out in order to run my application without specifying the codebase on the command line as required by the spec.
I assume you are going down this path because you are trying to start the rmi registry from the command line, and then trying to connect your server to it.
You might want to look at the java.rmi.registry.LocateRegistry class - in particular the createRegistry method. Using this you can start the registry from within your server application, which means taht your codebase will be automagically correct, and no security policy will be necessary.