?? helloclient.java
字號:
/* * @author javamxj (CSDN Blog) 創建日期 2004-12-27 */
import java.rmi.*;
import java.util.*;
import java.rmi.server.*;
import javax.rmi.PortableRemoteObject;
public class HelloClient
{
public static int i;
// private int c=0;
public static void main(String[] args)
{
// 在服務器端設置安全機制
/* if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } */
/* 默認為本地主機和默認端口 */
String host = "localhost:1099";
/* 帶輸入參數時,將host設置為指定主機 */
if (args.length > 0) host = args[0];
try
{
/* 根據指定的URL定位遠程實現對象 */
/* “h”是一個標識符,我們將用它指向實現“Hello”接口的遠程對象 */
Hello h = (Hello) Naming.lookup("rmi://" + host + "/HelloService");
//System.out.println("實現“Hello”接口的遠程對象: " + h);
//System.out.println("我在客戶端,開始調用RMI服務器端的'sayHello'方法");
// System.out.println("歡迎, " + h.sayHello("javamxj blog"));
for( i=2;i<=10;i++)
{
for(int j=1;j<=i;j++)
{
if(h.judge(j))
{
int k = i * 2 - j;
if (h.judge(k))
System.out.println((i*2)+"可分為"+j+"and"+k);
break;
}
}
}
} catch (Exception ex) { System.out.println("錯誤 " + ex); }
//c=1;
}
//public int Get() throws RemoteException
//{return i;}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -