?? main.java
字號:
/*
* Copyright 1999 by dreamBean Software,
* All rights reserved.
*/
package masteringrmi.helloworld.client;
import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.Properties;
import masteringrmi.helloworld.interfaces.HelloWorld;
/**
* This test application client locates a server object, and invokes it.
*
* This demonstrates a barebones client which is about as simple as it gets, RMI-wise at least.
*
* @see HelloWorld
* @author Rickard 謆erg (rickard@dreambean.com)
* @version $Revision:$
*/
public class Main
implements Runnable
{
// Static --------------------------------------------------------
/**
* Start the client as a stand-alone application.
*
* @param args
* @exception Exception
*/
public static void main(String[] args)
throws Exception
{
new Main().run();
}
// Public --------------------------------------------------------
// Runnable implementation ---------------------------------------
/**
* Run the client. Lookup the server from a RMI-registry, call it, and print the result.
*
*/
public void run()
{
try
{
// Locate remote object
HelloWorld server = (HelloWorld)Naming.lookup("rmi://localhost/"+HelloWorld.NAME);
// Call it
String result = server.helloWorld("World");
// Print result
System.out.println(result);
} catch (NotBoundException e)
{
System.out.println("The server could not be found");
e.printStackTrace(System.err);
} catch (MalformedURLException e)
{
System.out.println("The server name was incorrect");
e.printStackTrace(System.err);
} catch (Exception e)
{
System.out.println("The object could not be created");
e.printStackTrace(System.err);
}
}
/**
* @label Uses
*/
/*#HelloWorld Uses;*/
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -