Hi there,

I am wondering is there anyway to make a RMI connection in such a manor as to allow the remote methods to be called from anywhere in the application, without re initializing the original connection.

For example say I have a client with the class classmain.java -the main class with the main method and classgui.java and classloginscreen.java

Then a server with the interface class and the main implementation class.

Now in the client main I have

public RemoteServerInterface remote;

then in classmain I make a call to a method setup connection,
the method is as follows

try {
remote = (RemoteServerInterface)Naming.lookup("rmi://");

catch (RemoteException ee) {
System.out.println("RemoteException: " + ee.getMessage());

ok now I make an instance of clientgui from clientmain, and from clientgui i make an instance of classloginscreen. here I want to call for example


But I get a null pointer exception because remote is not defined. If I make a new variable as like the one in clientmain inside classloginscreen hence [public RemoteServerInterface remote; ] and
if I make a method inside classloginscreen which dose the code above, all works fine but I want to have one global connection so once I run classmain after that inside any other class I can just go remote.methodname();. is this possible or do I need to make a connection every time I am inside a different class.

any suggestions would be great.