´ÙÀ½ »çÇ×À» È®ÀÎÇØ º¸¼¼¿ä..


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :ÀÌ¿ø¿µ 1998³â 10¿ù 15ÀÏ 14:55:36

In Reply to: [´Ù½ÃÁú¹®ÀÌ¿ä...] posted by ¿µµ¹ÀÌ on 1998³â 10¿ù 09ÀÏ 14:35:15:


Local CLASSPATH¿¡ °üÇÑ ¾Æ·¡ÀÇ ³»¿ëÀ» È®ÀÎÇϼ¼¿ä..
http://java.freehosting.co.kr/java/messages/2821.html


Applet <-- RMI --> RMI Server -- JDBC -->Oracle DB
Çü½ÄÀÇ ±¸ÇöÀº ºÐ¸íÀÌ SimpleÇÏ°Ô µË´Ï´Ù.


¸ÕÀú JDKÀÇ ¿¹Á¦Áß RMI Hello¸¦ ¾à°£ ¼öÁ¤ÇÑ ¾Æ·¡ÀÇ
³»¿ëÀ» °¡Áö°í ¸ÕÀú testÇØ º¸½Ç °ÍÀ» ±ÇÇÕ´Ï´Ù.


[HelloInterface.java]
import java.rmi.*;
public interface HelloInterface extends java.rmi.Remote {
Object sayHello() throws java.rmi.RemoteException;
}


[HelloServer.java]
import java.net.*;
import java.util.*;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.registry.LocateRegistry;
public class HelloServer extends UnicastRemoteObject implements HelloInterface
{
private String name;
public HelloServer(String s) throws java.rmi.RemoteException {
super();
name = s;
}
public Object sayHello() throws RemoteException {
String string = new String("Hey! How are you? Im's Remote Server." );
return (Object)string;
}
public static void main(String args[]) {
int PORT = 7943;
try {
InetAddress address = InetAddress.getLocalHost();
String thisHost = address.getHostAddress();
Properties properties = System.getProperties();
properties.put("java.rmi.server.hostname", thisHost);
System.setProperties(properties);
System.setSecurityManager (new RMISecurityManager());
LocateRegistry.createRegistry( PORT );
HelloServer server = new HelloServer("HelloServer");
Naming.rebind("//:" + PORT + "/HelloServer", server);
}
catch (Exception e) {
System.out.println("HelloServer.main: an exception occurred:");
e.printStackTrace();
}
}
}


[HelloApplet.java]
import java.awt.*;
import java.rmi.*;
public class HelloApplet extends java.applet.Applet {
private final int PORT = 7943;
String message ;
TextArea t;
public void init() {
t = new TextArea();
setLayout(new BorderLayout());
add("Center", t);
try {
HelloInterface server = (HelloInterface) Naming.lookup("//" + getCodeBase().getHost() + ":" + PORT + "/HelloServer");
String message = (String)server.sayHello();
t.append(message + "\n");


} catch (Exception e) {
System.out.println("HelloApplet: an exception occurred:");
e.printStackTrace();
}
}
}


[HelloApplet.html]
<HTML>
<title>Hello World</title>
<center> <h1>Hello World</h1> </center>
The message from the HelloServer is:
<p>
<applet
code="HelloApplet.class"
width=500 height=120>
</applet>
</HTML>


±¸µ¿ ¹æ¹ý.
1. À§ÀÇ ¼¼°³ÀÇ .javaÆÄÀÏ°ú .htmlÆÄÀÏÀ» À¥¼­¹öÀÇ
Àû´çÇÑ ¹®¼­ µð·ºÅ丮¿¡ copyÇϼ¼¿ä.


2. javac *.java


3. rmic HelloServer


4. java HelloServer
(´ë±â»óÅ·ΠµÇ¸é RMI¼­¹ö°¡ Á¦´ë·Î ¶á °ÍÀÓ)
ȤÀº java HelloServer &


5. Netscape·Î À¥¼­¹öÀÇ HelloApplet.htmlÀ» Àо´Ù.


ºÐ¸íÈ÷ µÉ °Ì´Ï´Ù.
Çà¿îÀ»....



´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
HTML ÅÂ±× Æ÷ÇÔ ¿©ºÎ: HTML ¹®¼­ÀÏ °æ¿ì üũ
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]