Using RMI from applets

Hi everyone,
I have an applet that uses RMI to communicate with an RMI registry that is on the originating server for the applet. To enable the applet to make RMI calls over port 1099 I have had to modify the policy file of my Java plug-in (to grant socket permissions to the server over port 1099).
My understanding was that applets by default were able to communicate with their originating servers. Is this correct?
I am asking because I want end-users to be able to use this applet in their browsers without having to perform any security configurations. At the moment, if they don't have a Java plug-in, one will be automatically downloaded and installed on their system (which is great). But, as the application currently stands, they will then have to make an additonal step to modify their policy file.
This doesn't seem right to be. Any suggestions?
Thanks in advance.
Kind regards,
Ben Deany

I tried this a couple of years ago. In theory, it should work. If I remember correctly, I believe that the RMI API kept trying to crawl out of the sandbox by doing things that seemed to have no relation to RMI. Finally, I got a certificate and life got much simpler.

Similar Messages

  • Using RMI from another language

    I've been playing around with an idea of connecting to some Java library with RMI from a another programming language.
    I know that deep inside RMI uses sockets to send the data, so any language supporting sockets should be able to use RMI as well, it's a matter of creating the protocol for that language x.
    Does anyone if there's a library like this for any language?
    Is the RMI protocol free for studying? I found a couple of articles on RMI internals, but they don't go into this much of details.
    [http://www.developer.com/article.php/10915_3455311_3/Understanding-Java-RMI-Internals.htm|http://www.developer.com/article.php/10915_3455311_3/Understanding-Java-RMI-Internals.htm]
    [http://java.sun.com/developer/onlineTraining/rmi/RMI.html|http://java.sun.com/developer/onlineTraining/rmi/RMI.html]

    dave_spaghetti wrote:
    jtahlborn wrote:
    dave_spaghetti wrote:
    jtahlborn wrote:
    dave_spaghetti wrote:
    The RMI-IIOP sounds good, but the language(Flex/ActionScript) I was first thinking about does not have a CORBA support. Another need for an open source project maybe. I'll have to learn more about CORBA to see how complicated it is.doesn't flex/actionscript already have a java binding api?There's BlazeDS and GraniteDs, if that's what you meant. Those are Java EE apps running on top of an application server
    I'm thinking of something running local machine only. And like I said, I'm just thinking whether it would be possible at all.
    Edited by: dave_spaghetti on Mar 26, 2010 12:02 PMyes, that's what i was thinking of. the graniteds web page claims it runs on standalone tomcat or jetty. jetty is pretty lightweight. if it were me, i'd look at using these existing libraries before reinventing a (rather complex) wheel.Thanks for the reply and sorry for my reply coming so late.
    These are very valuable notes. I'll consider them. I think at least Tomcat has something called "embedded mode", which could be useful here.jetty has an embedded mode as well, we use it that way in our product. works great.

  • Contact EJB from Applet

    Hi all!
    Need urgent help. We try to contact an session ejb ( deployed to the OC4J - Server ). but it hangs , while creating the InitialContext !!! No exception, the programm stops only, while creating the new initialContext...
    It works great, when connecting the ejb from an application, but NOT from an applet. Is there somebody out there, having a solution for that problem ?? Or Somebody know an example, where an applet connects an EJB ??
    Please help.
    For further information : the source code :
    System.out.println("BEGIN getInitialContext() ...");
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.ApplicationClientInitialContextFactory");
    env.put(Context.PROVIDER_URL, "ormi://***.***.***.***/Server");
    env.put(Context.SECURITY_PRINCIPAL, "******");
    env.put(Context.SECURITY_CREDENTIALS, "*****");
    try {
    System.out.println(" BEGIN Create InitialContext");
    javax.naming.InitialContext ic = new javax.naming.InitialContext(env);
    System.out.println(" END Create InitialContext");
    System.out.println("END getInitialContext() ...");
    return ic;
    } catch (Exception e) {
    throw e;
    null

    could this be the reason, you don'y say what browser you are using.
    From IBM alphaworks site: http://www.alphaworks.ibm.com
    RMI for IE4 installs the missing Remote Method Invocation (RMI) support for the Microsoft Java virtual machine, thus enabling RMI for all Java applications that use the Microsoft Java virtual machine.
    Microsoft Internet Explorer 4.0 (IE 4.0) is one of the applications that uses Microsoft Java. Once installed, this package enables IE 4.0 to run applets that use RMI; such applets include the Java Management Applications for the IBM Nways Manager products.
    null

  • Format of  APDU using RMI

    hello
    I wanted to know the format of a APDU which is intended to invok a method (by using RMI) on applet supporting RMI.
    For example if I installed the applet "Myapplet" (it supports RMI) on the card and I wants to invok the method " boolean toto(short s=5, byte[]={03, 10} )"on this applet which is the format and the data which I must put in the APDU.
    Thank you

    Hello, I have the same problem. I want to install a RMI applet using JCOP 3.0 (Eclipse) and It gives me an error compiling the applet: no such clazz Ljavacard/framework/service/CardRemoteObject; But I have added this library to the build path (javacardframework.jar) and CardRemoteObject.class is in javacardframework.jar!! So, why is this error?
    How can I install my RMI Applet? Have I got to add more libraries? Have you solved this problem?
    Thank you.

  • Chat Applet using RMI .... trouble running the Applet using the IE browser.

    Hi,
    I'm trying to run a chat application using RMI technology. Actually, this wasn't created from the scratch. I got this one from from the cd that comes with the book I bought and I did some refinements on it to suit what I wanted to:
    These are the components of the chat application:
    1. RApplet.html - invokes the applet
    html>
    <head>
    <title>Sample Applet Using Dialog Box (1.0.2) - example 1</title>
    </head>
    <body>
    <h1>The Sample Applet</h1>
    <applet code="RApplet.class" width=460 height=160>
    </applet>
    </body>
    </html>
    2. RApplet.java - Chat session client applet.
    import java.rmi.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.io.*;
    import java.rmi.server.*;
    //import ajp.rmi.*;
    public class RApplet extends Applet implements ActionListener {
    // The buttons
    Button sendButton;
    Button quitButton;
    Button startButton;
    Button clearButton;
    // The Text fields
    TextField nameField;
    TextArea typeArea;
    // The dialog for entering your name
    Dialog nameDialog;
    // The name the server knows us as
    String privateName;
    // The name we want to be known as in the chat session
    String publicName;
    // The remote chats erver
    ChatServer chatServer;
    // The ChatCallback
    ChatCallbackImplementation cCallback;
    // The main Chat window and its panels
    Frame mainFrame;
    Panel center;
    Panel south;
    public void init() {
    // Create class that implements ChatCallback.
    cCallback = new ChatCallbackImplementation();
         // Create the main Chat frame.
         mainFrame = new Frame("Chat Server on : " +
                        getCodeBase().getHost());
         mainFrame.setSize(new Dimension(600, 600));
         cCallback.displayArea = new TextArea();
         cCallback.displayArea.setEditable(false);
         typeArea = new TextArea();
         sendButton = new Button("Send");
         quitButton = new Button("Quit");
         clearButton = new Button("Clear");
         // Add the applet as a listener to the button events.
         clearButton.addActionListener(this);
         sendButton.addActionListener(this);
         quitButton.addActionListener(this);
         center = new Panel();
         center.setLayout(new GridLayout(2, 1));
         center.add(cCallback.displayArea);
         center.add(typeArea);
         south = new Panel();
         south.setLayout(new GridLayout(1, 3));
         south.add(sendButton);
         south.add(quitButton);
         south.add(clearButton);
         mainFrame.add("Center", center);
         mainFrame.add("South", south);
         center.setEnabled(false);
         south.setEnabled(false);
         mainFrame.show();
         // Create the login dialog.
         nameDialog = new Dialog(mainFrame, "Enter Name to Logon: ");
         startButton = new Button("Logon");
         startButton.addActionListener(this);
         nameField = new TextField();
         nameDialog.add("Center", nameField);
         nameDialog.add("South", startButton);
         try {
         // Export ourselves as a ChatCallback to the server.
         UnicastRemoteObject.exportObject(cCallback);
         // Get the remote handle to the server.
         chatServer = (ChatServer)Naming.lookup("//" + "WW7203052W2K" +
                                  "/ChatServer");
         catch(Exception e) {
         e.printStackTrace();
         nameDialog.setSize(new Dimension(200, 200));
         nameDialog.show();
    * Handle the button events.
    public void actionPerformed(ActionEvent e) {
         if (e.getSource().equals(startButton)) {
         try {
              nameDialog.setVisible(false);;
              publicName = nameField.getText();
              privateName = chatServer.register(cCallback, publicName);
              center.setEnabled(true);
              south.setEnabled(true);
              cCallback.displayArea.setText("Connected to chat server as: " +
                             publicName);
              chatServer.sendMessage(privateName, publicName +
                             " just connected to server");
         catch(Exception ex) {
              ex.printStackTrace();
         else if (e.getSource().equals(quitButton)) {
         try {
              cCallback.displayArea.setText("");
              typeArea.setText("");
              center.setEnabled(false);
              south.setEnabled(false);
              chatServer.unregister(privateName);
              nameDialog.show();
         catch(Exception ex) {
              ex.printStackTrace();
         else if (e.getSource().equals(sendButton)) {
         try{
              chatServer.sendMessage(privateName, typeArea.getText());
              typeArea.setText("");
         catch(Exception ex) {
              ex.printStackTrace();
         else if (e.getSource().equals(clearButton)) {
         cCallback.displayArea.setText("");
    public void destroy() {
         try {
         super.destroy();
         mainFrame.setVisible(false);;
         mainFrame.dispose();
         chatServer.unregister(privateName);
         catch(Exception e) {
         e.printStackTrace();
    3. Chatcallback.java - interface used by clients to connect to the server.
    import java.rmi.*;
    public interface ChatCallback extends Remote {
    public void addMessage(String publicName,
                   String message) throws RemoteException;
    4. ChatcallbackImplementation.java - implements Chatcallback interface.
    import java.rmi.*;
    import java.io.*;
    import java.awt.event.*;
    import java.awt.*;
    public class ChatCallbackImplementation implements ChatCallback {
    // The buttons
    // The Text fields
    TextArea displayArea;
    public void addMessage(String publicName,
                   String message) throws RemoteException {
    displayArea.append("\n" + "[" + publicName + "]: " + message);
    5. Chatserver.java - interface for the chat server.
    import java.rmi.*;
    import java.io.*;
    public interface ChatServer extends Remote {
    public String register(ChatCallback object,
                   String publicName) throws RemoteException;
    * Remove the client associated with the specified registration string.
    * @param registeredString the string returned to the client upon registration.
    public void unregister(String registeredString) throws RemoteException;
    * The client is sending new data to the server.
    * @param assignedName the string returned to the client upon registration.
    * @param data the chat data.
    public void sendMessage(String registeredString, String message) throws RemoteException;
    6. ChatServerImplementation.java - implements Chatserver interface.
    import java.rmi.*;
    import java.util.*;
    import java.rmi.server.*;
    import java.io.*;
    * A class that bundles the ChatCallback reference with a public name used
    * by the client.
    class ChatClient {
    private ChatCallback callback;
    private String publicName;
    ChatClient(ChatCallback cbk, String name) {
         callback = cbk;
         publicName = name;
    // returns the name.
    String getName() {
         return publicName;
    // returns a reference to the callback object.
    ChatCallback getCallback() {
         return callback;
    public class ChatServerImplementation extends UnicastRemoteObject
    implements ChatServer {
    // The table of clients connected to the server.
    Hashtable clients;
    // Tne number of current connections to the server.
    private int currentConnections;
    // The maximum number of connections to the server.
    private int maxConnections;
    // The output stream to write messages to.
    PrintWriter writer;
    * Create a ChatServer.
    * @param maxConnections the total number if connections allowed.
    public ChatServerImplementation(int maxConnections) throws RemoteException {
         clients = new Hashtable(maxConnections);
         this.maxConnections = maxConnections;
    * Increment the counter keeping track of the number of connections.
    synchronized boolean incrementConnections() {
         boolean ret = false;
         if (currentConnections < maxConnections) {
         currentConnections++;
         ret = true;
         return ret;
    * Decrement the counter keeping track of the number of connections.
    synchronized void decrementConnections() {
         if (currentConnections > 0) {
         currentConnections--;
    * Register with the ChatServer, with a String that publicly identifies
    * the chat client. A String that acts as a "magic cookie" is returned
    * and is sent by the client on future remote method calls as a way of
    * authenticating the client request.
    * @param object The ChatCallback object to be used for updates.
    * @param publicName The String the object would like to be known as.
    * @return The actual String assigned to the object for removing, etc. or
    * null if the client could not register.
    public synchronized String register(ChatCallback object, String publicString) throws RemoteException {
         String assignedName = null;
         if (incrementConnections()) {
         ChatClient client = new ChatClient(object, publicString);
         assignedName = "" + client.hashCode();
         clients.put(assignedName, client);
         out("Added callback for: " + client.getName());
         return assignedName;
    * Remove the client associated with the specified registration string.
    * @param registeredString the string returned to the client upon registration.
    public synchronized void unregister(String registeredString) throws RemoteException {
         ChatCallback cbk;
         ChatClient sender;
         if (clients.containsKey(registeredString)) {
         ChatClient c = (ChatClient)clients.remove(registeredString);
         decrementConnections();
         out("Removed callback for: " + c.getName());
         for (Enumeration e = clients.elements(); e.hasMoreElements(); ) {
              cbk = ((ChatClient)e.nextElement()).getCallback();
              cbk.addMessage("ChatServer",
                        c.getName() + " has left the building...");
         else {
         out("Illegal attempt at removing callback (" + registeredString + ")");
    * Sets the logging stream.
    * @param out the stream to log messages to.
    protected void setLogStream(Writer out) throws RemoteException {
         writer = new PrintWriter(out);
    * The client is sending new message to the server.
    * @param assignedName the string returned to the client upon registration.
    * @param data the chat data.
    public synchronized void sendMessage(String registeredString, String message) throws RemoteException {
         ChatCallback cbk;
         ChatClient sender;
         try {
         out("Recieved from " + registeredString);
         out("Message: " + message);
         if (clients.containsKey(registeredString)) {
              sender = (ChatClient)clients.get(registeredString);
              for (Enumeration e = clients.elements(); e.hasMoreElements(); ) {
                   cbk = ((ChatClient)e.nextElement()).getCallback();
                   cbk.addMessage(sender.getName(), message);
         else {
              out("Client " + registeredString+ " not registered");
         catch(Exception ex){
         out("Exception thrown in newData: " + ex);
         ex.printStackTrace(writer);
         writer.flush();
    * Write s string to the current logging stream.
    * @param message the string to log.
    protected void out(String message){
         if(writer != null){
         writer.println(message);
         writer.flush();
    * Start up the Chat server.
    public static void main(String args[]) throws Exception {
         try {
         // Create the security manager
         System.setSecurityManager(new RMISecurityManager());
         // Instantiate a server
         ChatServerImplementation c = new ChatServerImplementation(10);
         // Set the output stream of the server to System.out
         c.setLogStream(new OutputStreamWriter(System.out));
         // Bind the server's name in the registry
         Naming.rebind("//" + args[0] + "/ChatServer", c);
         c.out("Bound in registry.");
         catch (Exception e) {
         System.out.println("ChatServerImplementation error:" +
                        e.getMessage());
         e.printStackTrace();
    Using my own machine (connected to a network), I tried to test this one out by setting mine as the server and also the client. I did the following:
    1. Compile the source code.
    2. Use rmic to generate the skeletons and/or stubs from the ChatCallbackImplementation and ChatServerImplementation.
    3. Start the rmiregistry with no CLASSPATH
    4. Start the server successfully.
    5. Start the applet using the AppletViewer command.
    It worked fined.
    The problem is when I ran the applet using the browser, IE explorer, the dialog boxes, frame and buttons did appear. I was able to do the part of logging on. But after that, the applet seemed to have hang. No message appeared that says I'm connected (which appeared using the appletviewer). I clicked the send button. No response.
    I double-checked my classpath. I did have my classpath set correctly. I'm still trying to figure out the problem. Up to now, I don't have any clue what it is.
    I will appreciate much if someone can help me figure what's could have possibly been wrong ....
    Thanks a lot ...

    Hi Domingo,
    I had a similar problem running applet/rmi with IE.
    Looking in IE..view..JavaConsole error messages my applet was unable to find java.rmi.* classes.
    I checked over java classes in msJVM, they're not present.
    ( WinZip C:\WINDOWS\JAVA\Packages\9rl3f9ft.zip and others from msVM installed )
    ( do not contain the java.rmi.* packages )
    I have downloaded and installed the latest msJVM for IE5. ( I think its included in later versions)
    @http://www.objectweb.org/rmijdbc/RJfaq.html I found ref to rmi.zip download to provide
    these classes. I couldn't get the classes from the site but I managed to find a ref to IBM
    site @http://alphaworks.ibm.com/aw.nsf/download/rmi which had similar download.
    The download however didn't solve my problems. I was unable to install rmi.zip with
    RmiPatch.exe install.
    I solved this by extracting the class files from rmi.zip and installing them at C:\WINDOWS\JAVA\trustlib ( msJVM installation trusted classes lib defined in
    registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Java VM\TrustedLibsDirectory )
    This solved the problem. My rmi/applet worked.
    Hope this helps you.
    Chris
    ([email protected])

  • Passing values from applet using POST method to PHP page

    Hello there ;)
    I realy need a help here.. I`ve been working all day on sending mail from applet. I didn`t succeed bcs of the security restrictions.
    So I decided just to pass arguments into PHP page, which process them and send e-mail to me.
    So here is the problem.. I need to send String variables througth POST into my php page. Now I`m using GET method, but I need more than 4000 characters.
    My actual solution is:
      URL url = new URL("http://127.0.0.1/index.php?name=" + name + "&message=" + message);
    this.getAppletContext().showDocument(url,"_self");I really need to rewrite it into POST. Would you be so kind and write few lines example [applet + php code]? I`ve already searched, googled, etc.. Pls don`t copy links to other forums here, probably I`ve read it.
    Thanx in advance to all :)

    hi!
    i`ve got some news about my applet.. so take this applet code:
    public class Apletik extends JApplet {
        public void init() { }
        public void start()
        try
          String aLine; // only if reading response
          String  parametersAsString = "msg=ahoj&to=world";
          byte[] parameterAsBytes = parametersAsString.getBytes();
          // send parameters to server
          URL url = this.getCodeBase();
          url = new URL(url + "spracuj.php");
          URLConnection con = url.openConnection();
          con.setDoOutput(true);
          con.setDoInput(true); // only if reading response
          con.setUseCaches(false);
          con.setRequestProperty("Content=length", String.valueOf(parameterAsBytes.length));
          OutputStream oStream = con.getOutputStream();
          oStream.write(parameterAsBytes);
          oStream.flush();
          String line="";
          BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
          while ((aLine = in.readLine()) != null)
           JOptionPane.showMessageDialog(null, aLine);      
           if(aLine.equals("")) break;
          in.close();      
          oStream.close();
        catch (Exception ex)
          JOptionPane.showMessageDialog(null, ex.toString());
    }here is code of spracuj.php which is on server:
    <?php
      if(isset($_POST['msg']))
        echo('hurray!');
    ?>it has only 1 problem.. when i test it on my localhost, everything seems to be all right. but when i post it to my server, i got IOException HTTP 400 error code :( where is the problem? please help me, i`m so close :D thanx

  • Call a Form using Webutil from the Menu loose focus on the applet

    Hello,
    I have the following problem:
    When calling a form using webutil from the menu the focus on the applet (I mean the Forms Application window) is lost and I have to click on the window to get back the focus on the application.
    Any advice ?
    Env: Forms 9i / Webutil 1.06
    Rgds,
    Philippe

    Try to use the NO_HIDE parameter in the CALL_FORM() built-in.
    Call_Form( 'the_form', NO_HIDE ) ;Or maybe, in the[b] When-New-Form-Instance trigger of the called form, return the focus to the calling form
    Go_Form( Get_Application_Property( CALLING_FORM ) ) ;Francois

  • How to access streaming vedio from server using RMI

    Hello please provide me the solution
    i have one vedio file in remote system and i want to import it to my local system using RMI after that i have to control it like vedio player.This entire application should be developed in struts.
    please give me a basic idea how to approch and wht r the files i need to import and is there any classes available to control the remote streaming vedio.

    If you are using Struts then you are in a web environment. So there is no RMI for the client (browser), it is just HTTP.
    About streaming video take a look at JMF (Java Media Framework). And if you are over HTTP you can use something like this to embed your video streaming:
    <html>
    <body>
    <object width="320" height="63"
    classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6"
    ccclassid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
    codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"
    standby="Cargando los componentes del Reproductor de Windows Media de Microsoft..."
    type="application/x-oleobject">
                <param name="filename" value="http://192.168.1.31:1025/01_Alegria.mp3">
                <param name="url" value="http://200.32.112.67/Estacion_del_Sol">
                <param name="AutoStart" value="true">
                <param name="volume" value="100">
                <param name="uiMode" value="mini">
                <embed type="application/x-mplayer2"
            pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"
            width=218
            height=129> </embed>
            </object>
                <param name="url" value="http://200.59.146.10/rockandpop-ba">
    </body>
    </html>Hope it helps

  • Is there any problems in IE if using RMI.?

    Hello buddies,
    this is my 3rd attempt to get answer. before it i tried 2 times but didn't get answered.
    actually i m making a chat application. in that there is a canvas on which we can draw something and send it to all users. i make an applet and from within the applet i m calling a frame. all this awt components like canvas and buttons etc. displays in the frame. applet is just a platform do call the frame. i m using RMI to do the chat. i tried to run it first in appletviewer and it works fine. but when i tried to run in IE from <applet> tag no frame is displays. i am trying to solve it from last 20 days but still unsolved. here is the code if anybody wishes to try it.
    // clinet frame...
    import java.rmi.*;
    import java.rmi.server.*;
    import canvas.Drawer;
    import java.awt.*;
    import java.applet.*;
    import java.applet.Applet;
    import java.awt.event.*;
    import java.util.*;
    import ru.zhuk.graphics.*;
    /*<applet code="ChatClient" width=600 height=300>
    </applet>
    public class ChatClient extends Frame implements IChatClient,ActionListener,MouseListener,MouseMotionListener
         // GLOBAL VARIABLES USED IN THE PROGRAMME...
         boolean flag=false;
         int n;
         String str="";
         String Coord=null;
         IChatService service=null;
         FrameApplet fa=null;
         TextField servername,serverport,username;
         Button connect,disconnect;
         TextField message;
         Button send,sendText;
         TextArea fromserver;
         int i=0,j=0;
         int x[] = new int[1000];
         int y[] = new int[1000];
         Drawer canvas;
         boolean connected=false;
         String title,user="";
         // Class Members //
         public ChatClient()
         public ChatClient(String str)
              super(str);
              setBounds(50,20,600,450);
              setLayout(new FlowLayout(FlowLayout.CENTER,45,10));
              title=str;
              setStatus();
              // Create controls //
              add(new Label("Chat Server Name : "));
              servername=new TextField(20);
              add(servername);
              servername.setText("localhost");
              add(new Label("Chat Server Port : "));
              serverport=new TextField(20);
              add(serverport);
              serverport.setText("900");
              add(new Label("Your User Name : "));
              username=new TextField(20);
              add(username);
              username.setText("Umesh");
              connect=new Button("Connect");
              connect.addActionListener(this);
              add(connect);
              disconnect=new Button("Disconnect");
              disconnect.addActionListener(this);
              add(disconnect);
              message=new TextField(30);
              add(message);
              sendText=new Button("Send Text");
              sendText.addActionListener(this);
              add(sendText);
              fromserver=new TextArea(10,50);
              add(fromserver);
              fromserver.setEditable(false);
    canvas = new Drawer();
              canvas.setSize(250,250);
              canvas.setBackground(Color.cyan);
              add(canvas);
              canvas.addMouseListener(this);
              canvas.addMouseMotionListener(this);
              send=new Button("Send");
              send.addActionListener(this);
              add(send);
              try
                   UnicastRemoteObject.exportObject(this);
              catch(Exception e)
              setVisible(true);
              for(j=0;j<1000;j++)
                   x[j]=0;
                   y[j]=0;
              Coord = new String();
              Coord = "";
    //          fa=new FrameApplet();
         public void mousePressed(MouseEvent me){}
         public void mouseReleased(MouseEvent me)
              Coord = Coord + "r";
         public void mouseClicked(MouseEvent me){}
         public void mouseEntered(MouseEvent me){}
         public void mouseExited(MouseEvent me){}
         public void mouseDragged(MouseEvent me)
              if (Coord == "")
                   Coord = me.getX() + "," + me.getY();
              else
                   Coord = Coord + " " + me.getX() + "," + me.getY();
         public void mouseMoved(MouseEvent me){}
         // RMI connection //
         private void connect()
              try
                   service = (IChatService)Naming.lookup("rmi://pcname/ChatService");
                   service.addClient(this);
                   connected=true;
                   setStatus();
                   user=username.getText();
                   Coord = "";
              catch(Exception e)
                   fromserver.append("Error Connecting ...\n" + e);
                   System.out.println(e);
                   connected=false;
                   setStatus();
                   service=null;
         private void disconnect()
              try
                   if(service==null)
                        return;
                   service.removeClient(this);
                   service=null;
              catch(Exception e)
                   fromserver.append("Error Connecting ...\n");
              finally
                   connected=false;
                   setStatus();
         private void setStatus()
              if(connected)
                   setTitle(title+" : Connected");
              else
                   setTitle(title+" : Not Connected");
         // IChatClient methods //
         public String getName()
              return user;
         public void sendMessage(String msg)
              fromserver.append(msg+"\n");
         public void SendCanvasObject(String str)
              this.str = str;
              fromserver.append(str + "\n");
              Graphics g = canvas.getGraphics();
              paint(g);
         // Actionlistener //
         public void actionPerformed(ActionEvent e)
              if(e.getSource()==connect)
                   connect();
                   if(connected)
                        servername.setEnabled(false);
                        serverport.setEnabled(false);
                        username.setEnabled(false);
                        connect.setEnabled(false);
                        Coord = "";
              else
              if(e.getSource()==disconnect)
                   disconnect();
                   servername.setEnabled(true);
                   serverport.setEnabled(true);
                   username.setEnabled(true);
                   connect.setEnabled(true);
              else
              if(e.getSource()==send)
                   flag = true;
                   if(service==null)
                        return;
                   try
                        fromserver.append("Sending an image...\n");
                        service.SendCanvasObject(this,Coord);
                        i=0;
                        for(j=0;j<1000;j++)
                             x[j]=0;
                             y[j]=0;
                        Coord = "";
                        fromserver.append("\n" + "Image Sent...");
                   catch(RemoteException re)
                        fromserver.append("Error Sending Message ...\n" + re);
                   catch(Exception ee)
                        fromserver.append("Error Sending Message ...\n" + ee);
              else
              if(e.getSource()==sendText)
                   if(service==null)
                        return;
                   try
                        service.sendMessage(this,message.getText());
                        message.setText("");
                   catch(RemoteException exp)
                        fromserver.append("Remote Error Sending Message ...\n" + exp);
                   catch(Exception ee)
                        fromserver.append("Error Sending Message ...\n" + ee);
         public void paint(Graphics g)
              if(flag==true)
                   i=0;
                   StringTokenizer stoken = new StringTokenizer(str,"r");
                   String strin = "";
                   while(stoken.hasMoreTokens())
                        strin = stoken.nextToken();
                        fromserver.append("\n" + strin + "\n");
                        StringTokenizer stoken1 = new StringTokenizer(strin," ");
                        String strin1 = "";
                        j=0;
                        while(stoken1.hasMoreTokens())
                             strin1 = stoken1.nextToken();
                             fromserver.append("\n" + strin1 + "\n");
                             x[j]=Integer.parseInt(strin1.substring(0,strin1.indexOf(",")));
                             y[j]=Integer.parseInt(strin1.substring(strin1.indexOf(",")+1,strin1.length()));
                             j++;
                        for(int k=0;k<j-1;k++)
                             g.drawLine(x[k],y[k],x[k+1],y[k+1]);     
                   i++;
    import java.rmi.*;
    import java.rmi.server.*;
    import canvas.Drawer;
    import java.util.*;
    import ru.zhuk.graphics.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    public class FrameApplet extends Applet implements ActionListener
         ChatClient f;
         public void init()
              Button b = new Button("Start Chat");
              b.addActionListener(this);
              add(b);
         public void actionPerformed(ActionEvent ae)
              f=new ChatClient("Chat");
              f.show();
              f.setSize(400,400);
    here is html file which i calls from IE
    <html>
    <title>Micky Chat</title>
    <body>
    <br>
    <br>
    <center>
    <applet code="FrameApplet.class" width=200 height=200>
    </applet>
    </center>
    </body>
    </html>
    and at last a shocking thing is it is runs in Netscape displaying frames but not calling paint method.
    pls. help me
    thanks a lot
    umesh

    Hi Umesh!
    Sorry that I cannot be too concrete about that since it has to be centuries ago when I fell over this problem.
    As far as I can remember, the JDK provided by MS has no RMI built-in. These was probably one of the main reasons why Sun sued Microsoft concering its handling of Java.
    Afterwards MS released a path for its Java Runtime that included RMI support, but AFAIK they never included it in the standard package. So much luck when searching for the ZIP! (-;
    A little bit of googling might help, e.g.:
    http://groups.google.com/groups?hl=de&lr=&ie=UTF-8&oe=UTF-8&threadm=37f8ddf6.4532124%40news.online.no&rnum=17&prev=/groups%3Fq%3Dmicrosoft%2Bjvm%2Brmi%2Bsupport%26start%3D10%26hl%3Dde%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3D37f8ddf6.4532124%2540news.online.no%26rnum%3D17
    cheers,
    kdi

  • What are the limitations of using RMI over http with EJB?

    We have a requirement for an intranet application where the majority of the clients
    (Swing clients) will be able to connect directly using either T3 or IIOP. However,
    there are a number of clients that will need to traverse a firewall.
    We could use SOAP, but I dont want to lose the value that RMI gives us (clustering,
    security, statefullness support etc). I am thinking of using RMI over http - which
    Weblogic supports.
    I have been trying to find some documentation on the topic - but havent succeded
    so far. What I would like to understand is: What limitations I would have using
    RMI over http. Do I lose anything (apart from performance) using http?
    Regards,
    Nick

    You will have to enable tunneling on the server side and I have not heard of any
    complaints of using it.
    Shiva.
    Nick Minutello wrote:
    In fact, we are not using applets - and its not an internet application. We are
    using Java Webstart and Swing on our intranet (the problem of the size of the
    weblogic.jar is a pain - but well known)
    The question for me is; Apart from performance, are there any limitations to using
    RMI over http?
    Can we also use JMS over http?
    -Nick
    Shiva Paranandi <[email protected]> wrote:
    "Old wine new bottle".
    The biggest problem with the approach of Applets like
    stuff connecting to weblogic is the size of the classes that need to
    be supplied to the
    users. The applets/swing would need a lot of weblogic classes which you
    need to
    supply as jar file. This file can be in the order of MBs depending on
    the
    weblogic version. we had a similar kind of problem and migrated the applets
    to use
    servlets instead of directly invoking ejbs or jms topics etc. Having
    the applets
    connect
    to servlets you would still benefit from the features of clustering etc.
    and added to
    that
    you would reduce the number of remote calls.
    Shiva.
    Nick Minutello wrote:
    We have a requirement for an intranet application where the majorityof the clients
    (Swing clients) will be able to connect directly using either T3 orIIOP. However,
    there are a number of clients that will need to traverse a firewall.
    We could use SOAP, but I dont want to lose the value that RMI givesus (clustering,
    security, statefullness support etc). I am thinking of using RMI overhttp - which
    Weblogic supports.
    I have been trying to find some documentation on the topic - but haventsucceded
    so far. What I would like to understand is: What limitations I wouldhave using
    RMI over http. Do I lose anything (apart from performance) using http?
    Regards,
    Nick

  • Possible to use RMI to upload client side image files?

    Is it possible to use RMI to upload client side image files? My intent is to allow remote clients to upload a number of small image files (jpg & gif) to a central server DBMS, by modifying a "Customer" object (eg adding a new Image object to a vector of Images?) Is this possible? Any suggestions greatly appreciated :))

    Is it possible to use RMI to upload client side image
    files? One possibility is to implement a serializable image object that you can upload to the server as any other object. When your server receives this serialized image object, just generate a new gif/jpg from it.
    But if your client-program is an applet, the situation is different: how can applet read image-file from users harddrive?
    krera

  • Class loading using rmi

    Hi
    I am developing my application as an applet .I use JMF in my application for media streaming. I need the required classes in javax.media and com.ibm( Really this does n't matter. I want to load some classes not written by me ) from a remote machine as reqiured in order to minimise the size of the applet. I cant define any interface since these are not my classes.Can any body give an idea regarding this
    A reply will be gratefully acknowledged
    Thank you

    The server must have all of the following class files in its class path:
    implementation (of course)
    interface
    stubs
    skeletons (if not using RMI version 1.2 stubs)
    The client should have only:
    implementation (of the client)
    interface
    The web server should have
    stubs
    any class files that are used on the server as return arguments for RMI calls that are not in the client.
    The classpath of rmiregistry should be empty
    The server's codebase should point to the root directory or jar file on the web server where the class files are located.
    Look at the web server's log files to see what files the client and rmiregistry are trying to load if you are getting errors.

  • Using MVC with Applet inside Servlet

    Hello fellow Java developers,
    I want to implement the Model View Controller concept inside a Bean Applet combination running in a servlet environment.
    When my model (the Bean) changes, I want my Applet (the View) to get notified so it can get the update from the Bean. The Applet is incorporated inside the jsp page (e.g. the servlet). The Bean is known inside the jsp. How do I make that same Bean known inside the Applet?
    When I create a new Bean during init, or in the constructor of the Applet, I get a complete other reference than the Bean inside the jsp. So, when I ask information from the Bean, I often get NullPointerExceptions, because I am referencing the wrong Bean.
    Does anyone have a solution for my problem?
    Regards,
    Michel

    hi,
    a servlet is server side object, an applet is client side object.
    For the communication, you should try HttpUrlConnection from applet to servlet.
    another way is tu use ejb, or rmi communcation

  • Can I manage APDU by myself if i use RMI model?

    Javacard - RMI , Can I manage APDU command by myself?
    First , there are 3 model of "Communicating with a Java Card Applet (Accessing the Smart Card)"
    1. The Message-Passing Model
    2. The Java Card RMI (JCRMI)
    3. The Security and Trust Services API (SATSA)
    This is my thinking/understanding
    I have seen that no manage APDU in RMIDemo. It look like programmer no need to manage APDU by themselves. RMI will manage it.
    (package com.sun.javacard.samples.RMIDemo; - > demo from java_card_kit-2_2_1)
    but another way -> "The Message-Passing Model" in JavaPurse ,wallet demo. all of these can manage APDU directly.
    Well, I want to know , Can I manage APDU by myself if i use RMI model?

    Javacard - RMI , Can I manage APDU command by myself?
    First , there are 3 model of "Communicating with a
    Java Card Applet (Accessing the Smart Card)"
    1. The Message-Passing Model
    2. The Java Card RMI (JCRMI)
    3. The Security and Trust Services API (SATSA) The last one is AFAIK not a separate model. SATSA uses APDU or JC-RMI to communicate with a java- / smartcard.
    This is my thinking/understanding
    I have seen that no manage APDU in RMIDemo. It look
    like programmer no need to manage APDU by themselves.
    RMI will manage it.
    (package com.sun.javacard.samples.RMIDemo; - > demo
    from java_card_kit-2_2_1)
    but another way -> "The Message-Passing Model" in
    JavaPurse ,wallet demo. all of these can manage APDU
    directly.
    Well, I want to know , Can I manage APDU by myself if
    i use RMI model?Yes you can.
    If you look into the PurseApplet.java you will notice in the process() method, that all APDUs your applet receives have to be passed to the RMI Service manually: disp.process(APDU);
    What you do with the APDU before passing it to the dispatcher (or after it) is up to you. You only have to make sure that you do not use the same INS value for your custom commands.
    By default the RMIService uses RmiService.DEFAULT_RMI_INVOKE_INSTRUCTION = 0x38 as INS value.
    Jan

  • RMI from client browser?

    I heard somebodies are developing solutions to do RMI from client browser,
    is this a good idea?

    The Limitations of RMI Applets on the Internet
    Although using RMI in Internet-based applets seems like a good idea, in practice, the instability of Internet connections and a lack of client support make it impractical. Among the obstacles to deploying RMI applets on the Internet are the following:
    * Despite supporting the majority of the Java 1.1 specification, the most popular web browsers -- Netscape Navigator and Microsoft Internet Explorer -- do not adequately support RMI. Navigator supports RMI on most platforms but does not support HTTP tunneling, so Netscape users connected to the web through a proxy server can't use an RMI applet. Meanwhile, Netscape for the Macintosh does not support RMI at all. Internet Explorer 4.0-5.0 also lacks RMI support, although a patch is supposedly available to add the missing classes (the RMI classes are available from Microsoft's web site, but instructions for installing them is not provided). As a result, a large percentage of Internet surfers can't use RMI applets in their current browser.
    * The RMI registry can experience problems when handling connections via the Internet. A bug that causes the registry to stop accepting new connections occurs all too frequently with web-based RMI clients, requiring that the registry be shut down and restarted. Also, in Java runtime environments prior to JDK 1.2.2, server sockets created to handle connections from Internet-based RMI clients can live on indefinitely (consuming server resources) even after those clients are shut down.
    * The RMI registry is not as flexible as most server applications, answering only to client connections made to one specific hostname. This means that your RMI server application cannot support multiple domains on a single web server, which limits your deployment options.
    * Many applications may require that data exchanged between client and server be encrypted, compressed, or handled in some other fashion. Doing this with RMI is simple enough, requiring only that you implement your own socket classes and an RMI socket factory that creates your special sockets. However, overriding the default socket factory disables RMI's ability to do HTTP tunneling, thereby preventing access by proxy server users.
    * Deploying an RMI server application requires additional network firewall configuration. By default, RMI objects are bound to random, "anonymous" server port numbers, making it impossible to predict the ports that must be available to Internet clients. RMI functionality new to Java 2 allows you to specify a port number when creating a remote object, but deployment still requires that firewalls allow access to ports not typically used by web-based applications.
    quoted from :
    http://developer.java.sun.com/developer/technicalArticles/RMI/rmi/
    AND when u get the sample code working, tell me how u did it. okay? :) thx! mail me at [email protected].

Maybe you are looking for