tags:

views:

177

answers:

1

I need to run my RMI server RmiEncodingServer) using the command line, my class files reside in this folder:

C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerClasses

in package hw2.rmi.server. The code base reside in this folder:

C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerCodeBase

in package hw2.rmi.server.

I use the command line:

java –classpath C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerClasses\ -Djava.rmi.server.codebase=file:/C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerCodeBase -Djava.security.policy=C:\workspace\distributedhw2\permissions.policy hw2.rmi.server.RmiEncodingServer

but I get a "class not found" exception as follows:

Exception in thread "main" java.lang.NoClassDefFoundError: ûclasspath
Caused by: java.lang.ClassNotFoundException: ûclasspath
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: GÇôclasspath.  Program will exit.

where have I gone wrong?

also, if you can provide instructions on how to run the server in eclipse, I added the following as a VM argument, but I get a class not found exception to a class that is in the RmiServerCodeBase:

-Djava.security.policy=C:\workspace\distributedhw2\permissions.policy -Djava.rmi.server.codebase=file:/C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerCodeBase

thanks

A: 

I found out that the problem was that I was trying to refer to the .java files in my codebase and not .class files, i suppose that propery name "codebase" is a bit misleading. so if you want to do it in your RMI server you can do it this way:

String codeBasePath =  "file:/C:/workspace/distributedhw2/"
        + "AgencyServers/RmiEncodingServer/RmiServerClasses/";
        System.setProperty("java.rmi.server.codebase",codeBasePath);

or simply pass the following as VM arguments:

-Djava.security.policy=C:\workspace\distributedhw2\permissions.policy -Djava.rmi.server.codebase=file:/C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerClasses
Noona