The Artima Developer Community
Sponsored Link

Java Answers Forum
Class Not Found in Server Application

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
mj deacon

Posts: 1
Nickname: mjdeacon
Registered: Dec, 2005

Class Not Found in Server Application Posted: Dec 9, 2005 2:19 AM
Reply to this message Reply
Advertisement
I have set up a basic server application. It contains three files namely
Arith.java (implements the Remote interface)
ArithImpl.java (implements Arith.java the server) and
ArithApp.java which is the client Application

All of these are in the same package. I have compiled all of these files and I execute the rmic ArithImpl command from within the ArithImpl.java file via Runtime.getRuntime.exec(...);
The stub and skeleton files are generated and still I get a class not found exception. I have checked the class path and these files are within the class path.
If anyone could help me I'd greatly appreciate it. Thanks


public class ArithImpl extends UnicastRemoteObject implements Arith{

public static final String HOST_NAME = "localhost";
public static final String ROOT = "C:/Work/Thesis~1/LearningRMI/";
public static final String CLASSPATH = ROOT;
public static final String POLICY_FILE = CLASSPATH+"policies/rmi.policy";
public static final String RMI_LOCATION = "C:/Progra~1/java/jdk1.5.0_03/bin/";

String objectName;

public ArithImpl(String s) throws RemoteException{
super();
objectName = s;
}

public int[] add(int[] a, int[] b) throws RemoteException {
int c[] = new int[10];
for (int i=0; i<10; i++)
c = a+b;
return c;
}

public static void main(String[] args) {
System.setProperty("java.security.policy",POLICY_FILE);
System.setProperty("j ava.class.path",CLASSPATH);


String rmic = RMI_LOCATION+"rmic -vcompat -classpath "+CLASSPATH+" "+ArithImpl.class.getName();
String registry = RMI_LOCATION+"\\rmiregistry";

try{
Runtime rt = Runtime.getRuntime();
rt.exec(rmic);
rt.exec(registry);
}
catch (IOException e){
e.printStackTrace();
}

RMISecurityManager sm = new RMISecurityManager();
System.setSecurityManager(sm);
try{
Naming.rebind("//"+HOST_NAME+"/ArithServer", obj);
System.out.println("ArithServer bound in registry");
}
catch (Exception e){
e.printStackTrace();
}
}

Topic: Importing classes again Previous Topic   Next Topic Topic: objects placed into arrays

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use