11 Replies Latest reply on Feb 25, 2013 1:04 PM by 992383

    remote JFileChooser

      Hi all,

      I think this topic could be of common interest. I try to implement a remote JFileChooser with RMI.

      I created a MyFileSystemView class on the client that extends FileSystemView and I also overwrote all methods, so that they delegate each call to a RemoteObject on the Server. This RemoteObject uses the class methods of:

      - return FileSystemView.getFileSystemView().getHomeDirectory(); and returns a file.

      Everything works fine when I run it on the same maschine, but If I separate it on a client and server I only get plain files(no directories) and I can not navigate at all.

      My question is:

      - Is it necessary to also implement the parameter File as an RemoteObject, like RemoteFile or just to implement a RemoteObject like RemoteFileView?

      - another question is: I wrote some comments about some of the people are passing the whole JFileChooser from the Server to the client. Is it not sufficient to only exchange the FileSystemView class and the the FileView class?

      Thanks for your time and effort!

      best regards,

        • 1. Re: remote JFileChooser

          In the end I found the following link in the forum:


          Here all my questions were answered(also with an example!)


          • 2. Re: remote JFileChooser
            hello sir..i am trying to develop a similar program to this. I wanted to view the thread of which uve posted the link above..but the thread appears to have been deleted.could you please guide me in developing a remote filechooser? i have worked with java, but not much with swings. and I do know RMI
            • 3. Re: remote JFileChooser
              It's quite easy to do, I wrote that thread.

              Basically you have to:

              1. write a RemoteFileSystemView that extends FileSystemView and ...
              2. delegates everything to a RemoteFileSystem remote interface that has the required methods, and
              3. a RemoteFileSystemServer that implements them.
              4. That in turn calls a local FileSystemView object to do the actual work at the remote system.

              The extra levels of complexity are there because FileSystemView itself isn't a remote interface. Then install the RemoteFileSystemView into your JFileChooser and there you are.
              • 4. Re: remote JFileChooser
                thanks a lot.. :) I will work with these things..
                • 5. Re: remote JFileChooser
                  The thread hasn't been deleted, that link was just to the sun forums. this is the relevant link to the migrated oracle forums:

                  Remote Browsing using RMI
                  • 6. Re: remote JFileChooser
                    I have referred the thread..trying to implement JFileChooser in RemoteFileSystemView..I don't know exactly how to do it. I have created an object of JFileChooser in the main function in RemoteFileSystemView but I am getting error for the following code
                                   fc = new JFileChooser(new File("/opt/myapp"), fs);
                    The error says cannot find constructor for JFileChooser.. can anybody help me?
                    Also, can anybody tell me what does the above constructor do?

                    Edited by: 989380 on 22-Feb-2013 09:47
                    • 7. Re: remote JFileChooser
                      Well if the compiler can't find it, it doesn't do anything because it doesn't exist.

                      Try the Javadoc.
                      • 8. Re: remote JFileChooser
                        I have written the following code in RemoteFileSystemView class (referred in the thread mentioned above).
                        public static void main(String args[])
                                  try {
                                  RemoteFileSystemView fsv = new RemoteFileSystemView(args[0]);
                                  JFileChooser fc;
                                  fc = new JFileChooser(new File("."), fsv);
                                  int status = fc.showDialog(null,"Select File"); 
                                  if (status == JFileChooser.APPROVE_OPTION)
                                  catch(Exception e)
                        It is giving me the following errors:
                        Feb 24, 2013 8:28:25 PM RemoteFileSystemView getHomeDirectory
                        SEVERE: getHomeDirectory()
                        java.rmi.NoSuchObjectException: no such object in table

                        I suppose RemoteFileSystemView is the clientside program and RemoteFileSystemServer and RemoteFileSystem are on the serverside. I do not know how to specify the current directory path in the JFileChooser constructor. Could someone guide me? And client is not supposed to know the exact path to the server machine. Then how do we make the current directory to be the server's documents directory? And am I going wrong some where?
                        • 9. Re: remote JFileChooser
                          That exception means that the stub is stale: the remote object it was derived from has been unexported, possibly DGC'd.

                          I wrote this seven years ago and cannot support it here, but it did work.
                          • 10. Re: remote JFileChooser
                            I got something working now..I have RemoteFileSystem, RemoteFileSystemServer at one location and at another location I have RemoteFileSystemView along with the interface and the stub file. When I run the corresponding steps for rmi, I get JFileChooser running showing the current directory oh the RemoteFileSystemView class. How do I change the current directory? and I can only access the drive where my RemoteFileSystemView class resides. I cannot access other drives except Desktop. can anybody help?
                            • 11. Re: remote JFileChooser
                              I got it working!! :)
                              i had to write the code for JFileChooser in the server program. It worked perfectly then.
                              Thank you all for your valuable support. This forum really helped me. Will surely come back here for more queries in future, if any.