jQuery in Action, 3rd edition
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes UrlyBird: Codebase file location Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "UrlyBird: Codebase file location" Watch "UrlyBird: Codebase file location" New topic

UrlyBird: Codebase file location

Dan Pike

Joined: Feb 10, 2006
Posts: 1
Hi Guys,

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:

System.setProperty("java.rmi.server.codebase", "file:/c:/.../runme.jar")

it works fine. If I try to set it using a relative path by using the command:

System.setProperty("java.rmi.server.codebase", "file:/runme.jar")

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.

Thanks Guys!

Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11778

Hi Dan,

Welcome to JavaRanch and this forum.

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.

Regards, Andrew

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Daniel Pike

Joined: Jan 19, 2006
Posts: 1
Thats great, thanks for your help andrew. I will take a look at this class and see how it goes.

Thanks again!
I agree. Here's the link: http://aspose.com/file-tools
subject: UrlyBird: Codebase file location
jQuery in Action, 3rd edition