4 Replies Latest reply: Feb 19, 2009 9:34 PM by 807588 RSS

    How can I make a jar executable file for a RMI program

    807588
      I have a program use rmi, package relation like this
      -MyProgram
      -----RMIServer
      ----------RMIInterface.java
      ----------RMIProgram.java
      -----RMIClient
      ----------RMIClientpro.java
      this program can running correctly.but I want to deploy it by single jar file
      so my jar file have this file:
      -MyProgram.jar
      -----RMIServer
      ----------RMIInterface.class
      ----------RMIProgram.class
      ----------RMIProgram_stub.class
      -----RMIClient
      ----------RMIClientpro.class
      -----META-INF
      ----------MANIFEST.MF
      but when I run this program. program throws exception ClassNoFound RMIServer.RMIProgram_stub.

      what can I do to correct this error?

      Edited by: Ulysess on Feb 13, 2009 8:19 PM
        • 1. Re: How can I make a jar executable file for a RMI program
          EJP
          I want to deploy it by single jar file
          Why? Why would you deploy the RMIProgram server class to the client? That's none of its business.
          but when I run this program. program throws exception ClassNotFound RMIServer.RMIProgram_stub.
          That's because the client needs the stub, and also the interface. So there's something wrong with the way you've packaged the JAR file. Incidentally the first listing you gave doesn't contain the stub: are you sure it isn't this one that fails?

          What you need is actually three JAR files: one for the server, containing only the server class; one for only the client, containg the client class; and one which is common to both, containg the remote interface and the stub.
          • 2. Re: How can I make a jar executable file for a RMI program
            807588
            Thank you for your post.
            Your answer is useful for me, but I'm not so familiar with deploy rmi program with jar. So I need further help.
            According to your post. I think I need deploy my program like this:

            RMIProgram_client.jar:
            -----Common
            ----------RMIInterface.class
            ----------RMIProgram_Stub.class
            -----RMIClient
            ----------RMIClientpro.class
            RMIProgram_server.jar:
            -----RMIServer
            ----------RMIProgram.class
            -----Common
            ----------RMIInterface.class
            ----------RMIProgram_Stub.class
            Is it right?
            But when I run the jar file, there's still throw NoClassFoundException of the stub

            I think it's to do with the manifest.mf file, it seems there are some more contents needed in the manifest.mf file.
            I create the jar package by Netbeans, so the contents of MANIFEST.MF like this:
            Manifest-Version: 1.0
            
            Ant-Version: Apache Ant 1.7.1
            
            Created-By: 11.0-b15 (Sun Microsystems Inc.)
            
            Main-Class: RMIServer.RMIProgram
            
            Class-Path: 
            
            X-COMMENT: Main-Class will be added automatically by build
            • 3. Re: How can I make a jar executable file for a RMI program
              EJP
              But when I run the jar file, there's still throw NoClassFoundException of the st
              When doing what? Exporting the server? Binding it to the Registry? Looking it up in the Registry? Executing a remote method?

              It makes a difference ...

              Most probably it is the Registry that can't find the class. Start the Registry with -J-classpath = the client JAR file.
              • 4. Re: How can I make a jar executable file for a RMI program
                807588
                Wanderful answer, That's the key point, Now My program run well