This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Distributed Java and the fly likes Trouble compiling RMI app. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Trouble compiling RMI app." Watch "Trouble compiling RMI app." New topic
Author

Trouble compiling RMI app.

Brian K Swingle
Ranch Hand

Joined: Jun 20, 2003
Posts: 39
Hello everyone,
I trying to compile this simple RMI chat example from Oreilly Java Servlet Programming book. This example has 3 parts, ChatClient.java, ChatServer.java and ChatServlet.java. I will post some of the example code here or you can download all 3 files from my server at this address.

http://www.powerleap.com/downloads/RMI-Chat-Code.zip

----------ChatClient.java---------------
import java.rmi.Remote;
import java.rmi.RemoteException;

public interface ChatClient extends Remote {
public void setNextMessage(String message) throws RemoteException;
}

-------------END--------------------------

This compiles just fine but the when i try to compile either of the other two examples like lets say. ChatServer.java i get this error.

---------- Java Compiler ----------
ChatServer.java:8: cannot resolve symbol
symbol : class ChatClient
location: interface ChatServer
public void addClient(ChatClient client) throws RemoteException;
^
ChatServer.java:9: cannot resolve symbol
symbol : class ChatClient
location: interface ChatServer
public void deleteClient(ChatClient client) throws RemoteException;
^
2 errors

Output completed (1 sec consumed) - Normal Termination
--------------end compile----------------------

The code for the chat server is short so i'll post it. here it is.

--------------ChatServer-----------------------
import java.rmi.Remote;
import java.rmi.RemoteException;

public interface ChatServer extends Remote {
public String getNextMessage() throws RemoteException;
public void broadcastMessage(String message) throws RemoteException;

public void addClient(ChatClient client) throws RemoteException;
public void deleteClient(ChatClient client) throws RemoteException;
}
--------------END------------------------------

From the error returned by the compiler it looks like ChatServer.java has to import ChatClient some how. To give you some background i've got all the correct Jar files needed and i'm compiling on my personal computer before uploading to my Solaris server. The ChatClient.class file is in the same directory as the ChatServer.java file i'm tring to compile. Any help on this would be greatly appreciated.

Thanks,
Brian
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

What's the classpath you're using to compile your classes? Is it missing '.' (the current directory)?


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Brian K Swingle
Ranch Hand

Joined: Jun 20, 2003
Posts: 39
This is my Classpath i have set in my system variables on my PC. What should i add if say i was compiling these examples from C:\Examples\ ?


CLASSPATH:

Thanks
Brian

(NP - edited due to really long line widening page...)
[ March 24, 2005: Message edited by: Nathan Pruett ]
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

The short answer is to add .; to the beginning of your classpath, so that the current directory is always loaded first. You could also add C:\Examples; to the classpath, but this isn't as good of a solution because it's hardcodng the specific path into the classpath, and you aren't *always* going to want C:\Examples on your classpath every time you run java.

Since '%CLASSPATH%' is inside the string you posted, there could be more set on the classpath... try typing 'echo %CLASSPATH%' on the console where you're compiling or running your program.

Also, you can remove that last entry in your classpath... "i/QTJava.zip" isn't a valid path at all.
Brian K Swingle
Ranch Hand

Joined: Jun 20, 2003
Posts: 39
Hello Nathan,
Thanks for all the help it compiles now. But now i'm having an issue with the applet that loads. But i'll post that in the applets forum. Thanks again for all your help.

Brian
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trouble compiling RMI app.
 
Similar Threads
Compile time Error(EJB)
Unable to compile home interface file
Cannot resolve Symbol (EJB)
Problem with MSDOS
Package usage problem