⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 remoteobject.java

📁 java的一系列产品中包括jsme,jmse,j2ee,本文件提供j2ee实现的源代码.
💻 JAVA
字号:
import java.rmi.Naming;

import java.io.Serializable;
/*or use this replace above announcement:
import java.rmi.server.UnicastRemoteObject;
*/
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;


public class RemoteObject implements java.io.Serializable, 
			RemoteInterface{
/*
or use this replace above announcement:
public class RemoteObject extends UnicastRemoteObject implement
			RemoteInterface{
*/	
	String name;
	public RemoteObject(String name) throws RemoteException{
		super();
		this.name=name;
	}
	
	public String message(String message) throws RemoteException{
		String returnString="My Name is:"+name+
				",thanks for your message:"+message;
		System.out.println("Returning:"+returnString);
		return "My Name is:"+name+",thanks for your message:"+message;
	}

  public static void main(String args[]){
  	//you can can shield SecurityManager
  	System.setSecurityManager(new RMISecurityManager());
  	try{
  		String myName="ServerTest";
  		RemoteObject theServer=new RemoteObject(myName);
  		Naming.rebind(myName,theServer);
  		/*or use this replace above:
  		  Naming.bind(myName,theServer);
  		*/
  		System.out.println("Ready to continue1");
  	}catch(Exception e){
  	  System.out.println("An exception occured while creating server");
  	}
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -