• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Trouble compiling RMI app.

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's the classpath you're using to compile your classes? Is it missing '.' (the current directory)?
 
Brian K Swingle
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Space seems cool in the movies, but once you get out there, it is super boring. Now for a fascinating tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic