Remote Browsing using RMI

Hi,
Read a lot of forums about how to create a Remote file browser using RMI and JFileChooser.
Not done any RMI coding I thought I'd give it a try. I have finally after 2 days managed to do it.
This is an overview.
Create a RemoteFile class that extends Remote.. eg.
import java.rmi.*;
import java.io.*;
import java.net.*;
public interface RemoteFile extends Remote {
    public boolean canRead() throws RemoteException;
    public boolean canWrite() throws RemoteException;
    public int compareTo(File pathname) throws RemoteException;etc.etc
Then create an implementation class...
import java.rmi.server.*;
import java.io.*;
import java.net.*;
public class RemoteFileImpl extends UnicastRemoteObject implements RemoteFile {
    private File f;
    public RemoteFileImpl(File sf) throws java.rmi.RemoteException {
        f=sf;
    public boolean canRead() throws java.rmi.RemoteException {
        return f.canRead();
    }etc etc for all other File functions.
Then we create a RemoteFileSystemView interface, again extending remote...
public interface RemoteFileSystemView extends Remote {
    public RemoteFile createFileObject(File dir, String filename) throws RemoteException;
    public RemoteFile createFileObject(String path) throws RemoteException;blah blah
Then An implementation class...
import javax.swing.filechooser.*;
import java.io.*;
public class RemoteFileSystemViewImpl extends java.rmi.server.UnicastRemoteObject implements RemoteFileSystemView {
    int length;
    private FileSystemView fs;
    public RemoteFileSystemViewImpl() throws java.rmi.RemoteException {
        fs=FileSystemView.getFileSystemView();
    public RemoteFile createFileObject(String path) throws java.rmi.RemoteException {
        return new RemoteFileImpl(fs.createFileObject(path));
    public RemoteFile createFileObject(java.io.File dir, String filename) throws java.rmi.RemoteException {
        return new RemoteFileImpl(fs.createFileObject(dir,filename));
    //public RemoteFileImpl createFileSystemRoot(java.io.File f) throws java.rmi.RemoteException {
    //    return new RemoteFileImpl(fs.createFileSystemRoot(f));
    public RemoteFile createNewFolder(java.io.File containingDir) throws java.rmi.RemoteException {
        RemoteFile tempf;
        try{
            tempf= new RemoteFileImpl(fs.createNewFolder(containingDir));
        } catch (IOException e){System.out.println(e); tempf=null;}
        return  tempf;
    public RemoteFile getDefaultDirectory() throws java.rmi.RemoteException {
        return new RemoteFileImpl(fs.getDefaultDirectory());
    public String[] getFiles(java.io.File dir, boolean useFileHiding) throws java.rmi.RemoteException {
        String[] tempf= new String[fs.getFiles(dir,useFileHiding).length];
        int i;
        File[] f = fs.getFiles(dir,useFileHiding);
        for(i=0;i<tempf.length;i++) tempf=f[i].toString();
return tempf;
public RemoteFile getHomeDirectory() throws java.rmi.RemoteException {
return new RemoteFileImpl(fs.getHomeDirectory());
public RemoteFile getParentDirectory(java.io.File dir) throws java.rmi.RemoteException {
return new RemoteFileImpl(fs.getParentDirectory(dir));
public String[] getRoots() throws java.rmi.RemoteException {
String[] tempf= new String[fs.getRoots().length];
System.out.println("fs is-"+fs.getRoots().length);
int i;
File[] f = fs.getRoots();
for(i=0;i<tempf.length;i++) {tempf[i]=f[i].toString();}
System.out.println("Roots="+tempf[0]);
return tempf;
public String getSystemDisplayName(java.io.File f) throws java.rmi.RemoteException {
return fs.getSystemDisplayName(f);
public javax.swing.Icon getSystemIcon(java.io.File f) throws java.rmi.RemoteException {
return fs.getSystemIcon(f);
public String getSystemTypeDescription(java.io.File f) throws java.rmi.RemoteException {
return fs.getSystemTypeDescription(f);
public boolean isComputerNode(java.io.File dir) throws java.rmi.RemoteException {
return fs.isComputerNode(dir);
public boolean isDrive(java.io.File dir) throws java.rmi.RemoteException {
return fs.isDrive(dir);
public boolean isFileSystem(java.io.File f) throws java.rmi.RemoteException {
return fs.isFileSystem(f);
public boolean isFileSystemRoot(java.io.File dir) throws java.rmi.RemoteException {
return fs.isFileSystemRoot(dir);
public boolean isFloppyDrive(java.io.File dir) throws java.rmi.RemoteException {
return fs.isFloppyDrive(dir);
public boolean isHiddenFile(java.io.File f) throws java.rmi.RemoteException {
return fs.isHiddenFile(f);
public boolean isParent(java.io.File folder, java.io.File file) throws java.rmi.RemoteException {
return fs.isParent(folder,file);
public boolean isRoot(java.io.File f) throws java.rmi.RemoteException {
return fs.isRoot(f);
public Boolean isTraversable(java.io.File f) throws java.rmi.RemoteException {
return fs.isTraversable(f);
public RemoteFile getChild(File parent, String fileName) throws java.rmi.RemoteException {
return new RemoteFileImpl(fs.getChild(parent,fileName));
Notice that whenever I should be passing a File, I pass a RemoteFile instead! Also.. when I am passing a File Array, I instead pass a String array. Reason is.. I havent managed to get File arrays through RMI.. Any Help anyone?!?!?!?!
I got round it by simply passing a String array and relying on the client to reconstruct a File array locally using the String array. Messy... perhaps.. any suggestions welcome!
Next.. use rmic to create Stubs and Skels for the 2 implementations and write an RMI server.. eg.
import java.rmi.Naming;
public class RemoteServerRMI {
    /** Creates a new instance of RemoteServerRMI */
    public RemoteServerRMI() {
        try {
            RemoteFileSystemView c = new RemoteFileSystemViewImpl();
            Naming.rebind("rmi://localhost:1099/FileService", c);
        } catch (Exception e) {
            System.out.println("Trouble: " + e);
    public static void main(String[] args) {
        new RemoteServerRMI();
}Yes.. simple and shamelessly lifted from the tutorials.
and Finally the client....
import javax.swing.filechooser.*;
import java.rmi.*;
import java.net.MalformedURLException;
import java.io.*;
import javax.swing.*;
public class RemoteFileSystemViewClient extends FileSystemView {
    static RemoteFileSystemView c;
    public RemoteFileSystemViewClient() {
        try {
            c = (RemoteFileSystemView) Naming.lookup("rmi://localhost:1099/FileService");
        catch (MalformedURLException murle) {
            System.out.println();
            System.out.println(
            "MalformedURLException");
            System.out.println(murle);
        catch (RemoteException re) {
            System.out.println();
            System.out.println(
            "RemoteException");
            System.out.println(re);
        catch (NotBoundException nbe) {
            System.out.println();
            System.out.println(
            "NotBoundException");
            System.out.println(nbe);
    public File getHomeDirectory() {
        File tempf;
        try {
            tempf= new File(c.getHomeDirectory().gettoString());
        } catch (RemoteException re){System.out.println(re);tempf=null;}
        return tempf;
    public File createFileObject(File dir, String filename) {
        File tempf;
        try {
            tempf= new File(c.createFileObject(dir, filename).gettoString());
        } catch (RemoteException re){System.out.println(re);tempf=null;}
        return tempf;
    public File createFileObject(String path) {
        File tempf;
        try {
            tempf=new File(c.createFileObject(path).gettoString());
        } catch (RemoteException re){System.out.println(re);tempf=null;}
        return tempf;
    public File createNewFolder(File containingDir) throws RemoteException {
        File tempf;
        try {
            tempf=new File(c.createNewFolder(containingDir).getAbsolutePath());
        } catch (RemoteException re){System.out.println(re);tempf=null;}
        return tempf;
    public File getChild(File parent, String fileName) {
        File tempf;
        try {
            tempf=new File(c.getChild(parent,fileName).gettoString());
        } catch (RemoteException re){System.out.println(re);tempf=null;}
        return tempf;
    public File getDefaultDirectory() {
        File tempf;
        try {
            tempf=new File(c.getDefaultDirectory().gettoString());
        } catch (RemoteException re){System.out.println(re);tempf=null;}
        return tempf;
    public File[] getFiles(File dir, boolean useFileHiding) {
        File[] tempf;
        try {
            tempf=new File[c.getFiles(dir,useFileHiding).length];
            String[] rtempf=c.getFiles(dir, useFileHiding);
            int i;
            for(i=0;i<c.getFiles(dir, useFileHiding).length;i++) tempf=new File(rtempf[i]);
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public File getParentDirectory(File dir) {
File tempf;
try {
tempf= new File(c.getParentDirectory(dir).gettoString());
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public File[] getRoots(){
File[] tempf;
try {
String[] rtempf= c.getRoots();
System.out.println("in");
tempf=new File[rtempf.length];
int i;
for(i=0;i<c.getRoots().length;i++) tempf[i]=new File(rtempf[i]);
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public String getSystemDisplayName(File f) {
String tempf;
try{
tempf=c.getSystemDisplayName(f);
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public javax.swing.Icon getSystemIcon(File f) {
javax.swing.Icon tempf;
try{
tempf=c.getSystemIcon(f);
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public String getSystemTypeDescription(File f) {
String tempf;
try {
tempf=c.getSystemTypeDescription(f);
} catch (RemoteException re){System.out.println(re);tempf=null;}
return tempf;
public boolean isComputerNode(File dir) {
boolean tempf;
try {
tempf= c.isComputerNode(dir);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public boolean isDrive(File dir) {
boolean tempf;
try {
tempf= c.isDrive(dir);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public boolean isFileSystem(File f) {
boolean tempf;
try {
tempf= c.isFileSystem(f);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public boolean isFileSystemRoot(File dir) {
boolean tempf;
try {
tempf= c.isFileSystemRoot(dir);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public boolean isFloppyDrive(File dir) {
boolean tempf;
try {
tempf= c.isFloppyDrive(dir);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public boolean isHiddenFile(File f) {
boolean tempf;
try {
tempf= c.isHiddenFile(f);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public boolean isParent(File folder, File file) {
boolean tempf;
try {
tempf= c.isParent(folder,file);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public boolean isRoot(File f) {
boolean tempf;
try {
tempf= c.isRoot(f);
} catch (RemoteException re){System.out.println(re);tempf=false;}
return tempf;
public Boolean isTraversable(File f) {
Boolean tempf;
try {
tempf= c.isTraversable(f);
} catch (RemoteException re){System.out.println(re);tempf=new Boolean(false);}
return tempf;
public static void main(String[] args) {
RemoteFileSystemViewClient rc = new RemoteFileSystemViewClient();
JFileChooser fch= new JFileChooser(rc);
fch.showOpenDialog(null);
Notice.. the getFiles and getRoots, procedures, get String arrays from the RMI and reconstruct local File arrays.
I managed to browse up and down directories with this, and even.. to my surprise, create folders!
If you got any improvements please let me know at [email protected]

Copyright &copy; Esmond Pitt, 2007. All rights reserved.
* RemoteFileSystem.java
* Created on 13 May 2007, 14:39
import java.io.File;
import java.io.IOException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import javax.swing.Icon;
* @author Esmond Pitt
public interface RemoteFileSystem extends Remote
     File createFileObject(String path) throws RemoteException;
     File[] getFiles(File dir, boolean useFileHiding) throws RemoteException;
     File createFileObject(File dir, String filename) throws RemoteException;
     File getChild(File parent, String fileName) throws RemoteException;
     boolean isFloppyDrive(File dir) throws RemoteException;
     boolean isFileSystemRoot(File dir) throws RemoteException;
     boolean isFileSystem(File f) throws RemoteException;
     boolean isDrive(File dir) throws RemoteException;
     boolean isComputerNode(File dir) throws RemoteException;
     File createNewFolder(File containingDir) throws RemoteException, IOException;
     File getParentDirectory(File dir) throws RemoteException;
     String getSystemDisplayName(File f) throws RemoteException;
     Icon getSystemIcon(File f) throws RemoteException;
     String getSystemTypeDescription(File f) throws RemoteException;
     File getDefaultDirectory() throws RemoteException;
     File getHomeDirectory() throws RemoteException;
     File[] getRoots() throws RemoteException;
     // File     createFileSystemRoot(File f) throws RemoteException;
import java.io.File;
import java.io.IOException;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Icon;
import javax.swing.filechooser.FileSystemView;
* @author Esmond Pitt
* @version $Revision: 3 $
public class RemoteFileSystemServer extends UnicastRemoteObject implements RemoteFileSystem
     private FileSystemView     fs = FileSystemView.getFileSystemView();
     private Logger     logger = Logger.getLogger(this.getClass().getName());
     /** Creates a new instance of RemoteFileSystemServer */
     public RemoteFileSystemServer(int port) throws RemoteException
          super(port);
          logger.log(Level.INFO, "exported on port {0} and receiving calls fs={1}", new Object[]{port, fs});
     public File createFileObject(String path)
          logger.log(Level.FINE, "createFileObject({0})", path);
          return fs.createFileObject(path);
     public File createFileObject(File dir, String filename)
          logger.log(Level.FINE, "createFileObject({0},{1})", new Object[]{dir, filename});
          return fs.createFileObject(dir, filename);
     public File[] getFiles(File dir, boolean useFileHiding)
          logger.log(Level.FINE, "getFiles({0},{1})", new Object[]{dir, useFileHiding});
          return fs.getFiles(dir, useFileHiding);
     public File getChild(File parent, String fileName)
          logger.log(Level.FINE, "getChild({0},{1})", new Object[]{parent, fileName});
          return fs.getChild(parent, fileName);
     public boolean isFloppyDrive(File dir)
          logger.log(Level.FINE, "isFloppyDrive({0})", dir);
          return fs.isFloppyDrive(dir);
     public boolean isFileSystemRoot(File dir)
          logger.log(Level.FINE, "isFileSystemRoot({0})", dir);
          return fs.isFileSystemRoot(dir);
     public boolean isFileSystem(File f)
          logger.log(Level.FINE, "isFileSystem({0})", f);
          return fs.isFileSystem(f);
     public boolean isDrive(File dir)
          logger.log(Level.FINE, "isDrive({0})", dir);
          return fs.isDrive(dir);
     public boolean isComputerNode(File dir)
          logger.log(Level.FINE, "isComputerNode({0})", dir);
          return fs.isComputerNode(dir);
     public File createNewFolder(File containingDir) throws IOException
          logger.log(Level.FINE, "createNewFolder({0})", containingDir);
          return fs.createNewFolder(containingDir);
     public File getParentDirectory(File dir)
          logger.log(Level.FINE, "getParentDirectory({0})", dir);
          return fs.getParentDirectory(dir);
     public String getSystemDisplayName(File f)
          logger.log(Level.FINE, "getSystemDisplayName({0})", f);
          return fs.getSystemDisplayName(f);
     public Icon getSystemIcon(File f)
          logger.log(Level.FINE, "getSystemIcon({0})", f);
          return fs.getSystemIcon(f);
     public String getSystemTypeDescription(File f)
          logger.log(Level.FINE, "getSystemTypeDescription({0})", f);
          return fs.getSystemTypeDescription(f);
     public File getDefaultDirectory()
          logger.log(Level.FINE, "getDefaultDirectory()");
          return fs.getDefaultDirectory();
     public File getHomeDirectory()
          logger.log(Level.FINE, "getHomeDirectory()");
          return fs.getHomeDirectory();
     public File[] getRoots()
          logger.log(Level.FINE, "getRoots()");
          return fs.getRoots();
      public File createFileSystemRoot(File f)
          return fs.createFileSystemRoot(f);
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Icon;
import javax.swing.filechooser.FileSystemView;
* @author Esmond Pitt
* @version $Revision: 4 $
public class RemoteFileSystemView extends FileSystemView
     private Logger     logger = Logger.getLogger(this.getClass().getName());
     private RemoteFileSystem     fs;
     public RemoteFileSystemView(String host)
     throws NotBoundException, RemoteException, MalformedURLException
          String     url = "rmi://"+host+"/"+RemoteFileSystem.class.getName();
          this.fs = (RemoteFileSystem)Naming.lookup(url);
          logger.log(Level.INFO, "Connected to {0} via {1}", new Object[]{url, fs});
     public File createFileObject(String path)
          logger.entering(this.getClass().getName(), "createFileObject", path);
          try
               return fs.createFileObject(path);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "path="+path, exc);
               return null;
     public File[] getFiles(File dir, boolean useFileHiding)
          logger.entering(this.getClass().getName(), "getFiles", new Object[]{dir, useFileHiding});
          try
               return fs.getFiles(dir, useFileHiding);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "dir="+dir+" useFileHiding="+useFileHiding, exc);
               return null;
     public File createFileObject(File dir, String filename)
          logger.entering(this.getClass().getName(), "createFileObject", new Object[]{dir, filename});
          try
               return fs.createFileObject(dir, filename);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "dir="+dir+" filename="+filename, exc);
               return null;
     public File getChild(File parent, String fileName)
          logger.entering(this.getClass().getName(), "getChild", new Object[]{parent, fileName});
          try
               return fs.getChild(parent, fileName);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "parent="+parent+" fileName="+fileName, exc);
               return null;
     public boolean isFloppyDrive(File dir)
          logger.entering(this.getClass().getName(), "isFloppyDrive", dir);
          try
               return fs.isFloppyDrive(dir);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "dir="+dir, exc);
               return false;
     public boolean isFileSystemRoot(File dir)
          logger.entering(this.getClass().getName(), "isFileSystemRoot", dir);
          try
               return fs.isFileSystemRoot(dir);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "dir="+dir, exc);
               return false;
     public boolean isFileSystem(File file)
          logger.entering(this.getClass().getName(), "isFileSystem", file);
          try
               return fs.isFileSystem(file);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "file="+file, exc);
               return false;
     public boolean isDrive(File dir)
          logger.entering(this.getClass().getName(), "isDrive", dir);
          try
               return fs.isDrive(dir);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "dir="+dir, exc);
               return false;
     public boolean isComputerNode(File dir)
          logger.entering(this.getClass().getName(), "isComputerNode", dir);
          try
               return fs.isComputerNode(dir);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "dir="+dir, exc);
               return false;
     public File createNewFolder(File containingDir) throws IOException
          logger.entering(this.getClass().getName(), "createNewFolder", containingDir);
          try
               return fs.createNewFolder(containingDir);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "containingDir="+containingDir, exc);
               return null;
     public File getParentDirectory(File dir)
          logger.entering(this.getClass().getName(), "getParentDirectory", dir);
          try
               return fs.getParentDirectory(dir);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "dir="+dir, exc);
               return null;
     public String getSystemDisplayName(File file)
          logger.entering(this.getClass().getName(), "getSystemDisplayName", file);
          try
               return fs.getSystemDisplayName(file);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "file="+file, exc);
               return null;
     public Icon getSystemIcon(File file)
          logger.entering(this.getClass().getName(), "getSystemIcon", file);
          try
               return fs.getSystemIcon(file);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "file="+file, exc);
               return null;
     public String getSystemTypeDescription(File file)
          logger.entering(this.getClass().getName(), "getSystemTypeDescription", file);
          try
               return fs.getSystemTypeDescription(file);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "file="+file, exc);
               return null;
     public File getDefaultDirectory()
          logger.entering(this.getClass().getName(), "getDefaultDirectory");
          try
               return fs.getDefaultDirectory();
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "getDefaultDirectory()", exc);
               return null;
     public File getHomeDirectory()
          logger.entering(this.getClass().getName(), "getHomeDirectory");
          try
               return fs.getHomeDirectory();
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "getHomeDirectory()", exc);
               return null;
     public File[] getRoots()
          logger.entering(this.getClass().getName(), "getRoots");
          try
               return fs.getRoots();
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "getRoots()", exc);
               return null;
     protected File createFileSystemRoot(File file)
          logger.entering(this.getClass().getName(), "createFileSystemRoot", file);
          logger.log(Level.SEVERE, "createFileSystemRoot called with ({0})", new Object[]{file});
          try
               return fs.createFileSystemRoot(file);
          catch (RemoteException exc)
               logger.log(Level.SEVERE, "", exc);
          return null;
}

Similar Messages

  • How to capture the remot desktop using RMI?

    Hi friends..
    I am doing a mini project to capture the remot desktop using RMI. I am very new with this subject. So 'm waiting for the help of experts...

    You can't. RMI doesn't do that. After you have captured it, some other way, you can transmit it via RMI, or plain Sockets, or several other ways.

  • Accessing Remote PC Using RMI

    Hello friends.
    We have developed an Explorer(Windows style) Using RMI which can browse any client computer (shared/non shared).
    It works quite well but we have some problem like not all file/folders
    are accessible(though they are visible).
    All those interested can help me out.
    Source with details are available at
    geocities.com/dev.sushant/rmi

    As Bob rightly says you may have a problem if the machine you are trying to access is on a corporate network as you will need the permission and help of the network administrator to achieve this.
    I assume from your post that there is not a VPN connection set up on the remote PC network. Assuming that you have access to the router on the remote network then you will need to set up portforwarding on it at some point so I suggest you go to this page and see if your router is listed as you will need some instructions if you don't use the software suggested by Bob.
    When accessing a remote machine, PC or Mac, I have always used a secure connection to do so and the alternative to a VPN is an SSH tunnel. Unfortunately unlike the Mac Windows doesn't come with SSH server software installed so if you want to go down this route you will have to install and configure this first. I haven't tried this on Windows 7 yet but I have been successful on Windows XP and there are plenty of sites with instructions on how to set this up like this one here. Once the SSH server is set up on the PC and port 22 on your remote router has been forwarded then you can set up a SSH tunnel in the same way as described in my post in this thread http://discussions.apple.com/thread.jspa?messageID=10847513&#10847513
    Message was edited by: Sean Dale1

  • Remote Desktop in RMI

    hi
    if any one having the coding to connect remote machine using RMI...
    it is possible to do it in JAVA ?
    because i need application like GoToMyPc...
    pls help

    hi
    if any one having the coding to connect remote
    machine using RMI...RMI is not a remote desktop technology. It is one of several technologies you could use to build such a thing.
    it is possible to do it in JAVA ?I suspect not without some JNI code.
    because i need application like GoToMyPc...so why not buy GoToMyPc?

  • 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])

  • 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

  • Remote desktop and RMI

    Is RMI the right choice for developing a remote desktop application (sending mouse and keys events and receive screen shots) ?

    That's not a reason, that's just a (fallacious) assertion about using RMI for anything. In fact, 'managing the RMI server' is probably the easiest part of RMI.
    The reason I said it isn't appropriate is that the communications primitives you need can't be sensibly expressed as procedure calls. You have a stream of screen information flowing between the remote and the peer, and you may have occasional keyboard/mouse events going the other way if you implement remote control. RMI is a completely inappropriate choice for this.

  • 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

  • Problem in connecting remote server using Applet?

    Hello everybody,
    I am facing problem in connecting to remote server using Applet in browser. I am using JDK 1.5.0_12 and running the application on apache 2.2.
    Firstly I have tried with simple jar file which could not connect to remote server and throws permission denied than now I am trying with signed jar file but also not working. I have changed the java.policy file of JDK in server with grant all Permission but also it throws "java.security.AccessControlException:access denied(java.net.SocketPermission 127.0.0.1:1521 connect, resolve)".
    Can anybody suggest me how to solve this problem?
    Thank You.
    -Ritesh

    >
    I am facing problem in connecting to remote server using Applet in browser.
    Firstly I have tried with simple jar file which could not connect to remote server and throws permission denied than now I am trying with signed jar file but also not working. >Were you prompted to accept the digitally signed code? To see what I mean, check out the [Defensive loading of trusted applets demo|http://pscode.org/test/docload/]. If you are not getting the prompt, or refused it, follow the link to sandbox.html for tips on how to proceed.

  • How do I make a RMI client running in Bea find a remote, non Bea, RMI server?

    On my stand alone test system I run a RMI server in one JVM,
    registry.exe and a RMI client in its own JVM. The client uses
    java.rmi.Naming.lookup() to find the RMI server, and this works fine.
    If I run the same RMI client class within Bea the naming lookup fails! I
    guess this is due to Bea using it own RMI registry rather than the
    registry.exe I started separately(?)
    QUESTION: How do I make a RMI client running in Bea find a remote,
    non-Bea, RMI server?
    Of course, in the final environment the server will run on a system
    remote from Bea.
    The RMI client calls are done from a servlet, not from a EJB.
    The doumentation about using RMI with Bea is focused on running the RMI
    server within Bea. This might be the "normal" thing to do, but in our
    case Bea is the client, not the server. Do I still need to use
    weblogic.rmi.*....? If so, where?
    Grateful for any tip.
    Göran Hagnell

    On my stand alone test system I run a RMI server in one JVM,
    registry.exe and a RMI client in its own JVM. The client uses
    java.rmi.Naming.lookup() to find the RMI server, and this works fine.
    If I run the same RMI client class within Bea the naming lookup fails! I
    guess this is due to Bea using it own RMI registry rather than the
    registry.exe I started separately(?)
    QUESTION: How do I make a RMI client running in Bea find a remote,
    non-Bea, RMI server?
    Of course, in the final environment the server will run on a system
    remote from Bea.
    The RMI client calls are done from a servlet, not from a EJB.
    The doumentation about using RMI with Bea is focused on running the RMI
    server within Bea. This might be the "normal" thing to do, but in our
    case Bea is the client, not the server. Do I still need to use
    weblogic.rmi.*....? If so, where?
    Grateful for any tip.
    Göran Hagnell

  • Will multiple Lan cards cause problems using rmi?

    Will multiple Lan cards cause problems using rmi? If a host has two or more network cards (only one of which is Internet-enabled), how does RMI know which IP address to use? There seems to be a problem when such a client registers with an RMI service, and has a client-side callback method invoked by the server.

    You can tell RMI the address you want by defining java.rmi.server.hostname at the JVM which exports the remote object.

  • Select,delete in MS ACcess using RMI

    Hi,
    I am using RMI in order to remotely connect to an MS Access database
    But when executing the following
    Statement stmt_access;
    String res1_access = "DELETE FROM CUSTOMERS WHERE cid='"+CID+"' ";
    stmt_access.executeUpdate(res1_access);
    I am getting the error
    data type mismatch in criteria...
    Does anyone know if there is something in my statement?
    CID is a String and cid is a defined as a Text field in Access database.
    I should mention that the same statement works fine in Oracle.
    Is there any difference in the syntax of select and delete statements in MS Access?Because I suppose that the error is in thw where clause(in insert statements i don't have problems)
    I would be greatfull if someone has an idea...

    Seems to be some confusion in the above.
    You need to post the exact statements that are causing the problem.
    For your code the way to produce those is by using System.out.println() on the line before you use it. That does not mean by guessing or by printing it out twenty lines before.
    And the create statement is the one that you used to create the database, again not just a guess on your part correct?
    Keep in mind that if you do not get a SQLException then it means all of the SQL is executing correctly, but something is wrong with the data (or your presumptions about the data) which is the problem.

  • How to create a file on a remote machine using PrintStream

    I want to create an HTML file on a remote machine connect via LAN the path is "\\vineet\akh\" akh is folder where I want to save the HTML file. Now in PrintStream i can give only a local file. Please help how to do it

    .. You can do this in two ways!!
    1) easy way
    2) hard way
    1) EASY WAY
    .. as you know for write to a remote dir you must
    a) have shared remote dir
    b) have write permit on remote dir
    if you have point a) and b) the way to follow it's simple as the other user explained to you!!
    2) HARD WAY
    the hard way is to use RMI (Remote Method Invokation)
    i mean to create a service on a remote machine that give to you a remote method that make you write without share anything..!!!
    check it out
    http://tns-www.lcs.mit.edu/manuals/java-api-1.1beta2/guide/rmi/
    i hope i'm been clear!!
    SORRy My english!! (please)
    Alessandro

  • How to use RMI Stub class in programming?

    Hi all,
    I'm new on RMI.
    Is there anyone can explain to me how to use RMI Stub class which is generated by invoking rmic command?
    For my testing, I can only invoke rmi object nethod via its remote interface. Then what is stub used for when we are coding?
    I do appreciate anyone's help.
    Thanks very much,
    Xianyi.Ye

    When the remote object binds itself to the registry, what is actually bound is the stub.
    So when the client does a registry lookup, what it gets is the stub. However from the client's point of view it is just some mystery object that implements the remote interface.
    So you never have to use it directly, it is all automatic.

Maybe you are looking for