Posted By:
ajay_kemparaj
Posted On:
Thursday, March 30, 2006 02:43 AM
Can any one help to execute the following code ...it has 4 parts ...got it from the web .... interface ,serverimpl,server,client ...but there is no compilation errors its is resylting in runtime exception like stubgeneration failed interface.java import java.rmi.*; import java.rmi.server.*; public interface intf extends Remote { public void shutdown() throws RemoteException; } Implementation Java file import java.util.*; import java.io.*; import java.rmi.*; import java.rmi.server.*; public class Serverimpl extends UnicastRemoteObject implements intf { public Serverimpl() throws RemoteException {} public voi
More>>
Can any one help to execute the following code ...it has 4 parts ...got it from the web .... interface ,serverimpl,server,client ...but there is no compilation errors its is resylting in runtime exception like stubgeneration failed
interface.java
import java.rmi.*;
import java.rmi.server.*;
public interface intf extends Remote
{
public void shutdown() throws RemoteException;
}
Implementation Java file
import java.util.*;
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
public class Serverimpl extends UnicastRemoteObject implements intf
{
public Serverimpl() throws RemoteException
{}
public void shutdown()
{
try
{
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("shutdown -l");
}
catch(Throwable t)
{
t.printStackTrace();
}
}
}
Server Java file
import java.rmi.*;
import java.rmi.server.*;
public class Server
{
public static void main(String arg[]) throws Exception
{
Serverimpl impl = new Serverimpl();
System.out.println("Initialising server.........");
Naming.rebind("rajesh",impl);
System.out.println("Registered");
}
}
Client java file
import java.rmi.*;
import java.rmi.server.*;
public class Client
{
public static void main(String args[]) throws Exception
{
String url = "rmi://192.0.0.100/rajesh";
intf intf1 = (intf)Naming.lookup(url);
intf1.shutdown();
}
}
<<Less