classpath problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oll3i
    Contributor
    • Mar 2007
    • 679

    #1

    classpath problems

    Code:
    package hello_rmi_iiop;
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    
    public interface HelloInterface extends Remote {
    	   public void sayHello( String from ) throws RemoteException;
    	}
    
    
    
    package hello_rmi_iiop;
    
    //HelloImpl.java
    import java.rmi.RemoteException;
    import javax.rmi.PortableRemoteObject;
    
    public class HelloImpl extends PortableRemoteObject implements HelloInterface {
       public HelloImpl() throws RemoteException {
           super();     // invoke rmi linking and remote object initialization
       }
    
       public void sayHello( String from ) throws RemoteException {
           System.out.println( "Hello from " + from + "!!" );
           System.out.flush();
       }
    }

    when i try to compile HelloImpl i get an error
    D:\JAVA_P~1\Z1\ SRC\HELLO_~1>ja vac -d . -classpath . HelloImpl.java
    HelloImpl.java: 7: cannot find symbol
    symbol: class HelloInterface
    public class HelloImpl extends PortableRemoteO bject implements HelloInterface {
    ^
    1 error
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Are the .java files stored in a subdirectory hello_rmi_iiop? As a rule of thumb,
    the source files directory structure should be the same as your .class file
    directory structure.

    kind regards,

    Jos

    Comment

    • oll3i
      Contributor
      • Mar 2007
      • 679

      #3
      yes they are all in hello_rmi_iiop ..
      HelloClient.jav a
      HelloImpl.java
      HelloInterface. java
      and HelloServer.jav a

      Comment

      • oll3i
        Contributor
        • Mar 2007
        • 679

        #4
        i solved it :) thank you

        Comment

        • oll3i
          Contributor
          • Mar 2007
          • 679

          #5
          but rmic -iiop HelloImpl returns an error
          D:\JAVA_P~1\Z1\ SRC\HELLO_~1>rm ic -iiop HelloImpl
          error: Class HelloImpl not found.
          1 error

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by oll3i
            yes they are all in hello_rmi_iiop
            Then your directory structure is goofy. Do this instead:
            Code:
            <path>/java/src/hello_rmi_iiop
            <path>/java/src/other_package
            <path>/java/classes
            You already stored your .java files in the correct directory but you don't want
            your .class files in there or in a subdirectory thereof. Move to the directory
            <path>/java/src in order to compile any java file and type this:
            Code:
            javac -classpath ../classes -d ../classes -sourcepath . hello_rmi_iiop/*.java
            This tells the javac compiler to store the compiled files at the directory specified
            by the -d flag which happens to equal the classpath for the moment. Other
            source files can be found at the directory specified by the -sourcepath flag.

            That way you build up two identical directory structures: one for the .class
            files and one for your .java source files. The "classes" directory structure serves
            fine as a classpath root directory.

            kind regards,

            Jos

            Comment

            • oll3i
              Contributor
              • Mar 2007
              • 679

              #7
              still error :(
              Katalog: D:\JAVA_P~1\CLA SSES

              2007-05-09 21:50 <DIR> .
              2007-05-09 21:50 <DIR> ..
              2007-05-09 21:50 1*238 HelloClient.cla ss
              2007-05-09 21:50 708 HelloImpl.class
              2007-05-09 21:50 228 HelloInterface. class
              2007-05-09 21:50 998 HelloServer.cla ss
              4 plik(ów) 3*172 bajtów
              2 katalog(ów) 7*812*845*568 bajtów wolnych

              D:\JAVA_P~1\CLA SSES>rmic -iiop HelloImpl
              error: Class HelloImpl not found.
              1 error

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by oll3i
                still error :(
                Katalog: D:\JAVA_P~1\CLA SSES

                2007-05-09 21:50 <DIR> .
                2007-05-09 21:50 <DIR> ..
                2007-05-09 21:50 1*238 HelloClient.cla ss
                2007-05-09 21:50 708 HelloImpl.class
                2007-05-09 21:50 228 HelloInterface. class
                2007-05-09 21:50 998 HelloServer.cla ss
                4 plik(ów) 3*172 bajtów
                2 katalog(ów) 7*812*845*568 bajtów wolnych

                D:\JAVA_P~1\CLA SSES>rmic -iiop HelloImpl
                error: Class HelloImpl not found.
                1 error
                the rmi stub compiler compiles stubs from .class files so you should go to
                the "classes" directory and compile like this:
                Code:
                rmic hello_rmi_iiop.HelloImpl
                kind regards,

                Jos

                Comment

                • oll3i
                  Contributor
                  • Mar 2007
                  • 679

                  #9
                  D:\JAVA_P~1\CLA SSES>rmic hello_rmi_iiop. HelloImpl
                  error: Class hello_rmi_iiop. HelloImpl not found.
                  1 error

                  Comment

                  • JosAH
                    Recognized Expert MVP
                    • Mar 2007
                    • 11453

                    #10
                    Originally posted by oll3i
                    D:\JAVA_P~1\CLA SSES>rmic hello_rmi_iiop. HelloImpl
                    error: Class hello_rmi_iiop. HelloImpl not found.
                    1 error
                    You have to be a bit more verbose, now I can only guess:

                    1) Did you change your cwd to the classes directory?
                    2) Is that .class file really there?
                    3) Did javac keep its mouth shut?

                    kind regards,

                    Jos

                    Comment

                    • oll3i
                      Contributor
                      • Mar 2007
                      • 679

                      #11
                      i change the directory to classes directory the HelloImpl.class is there
                      and javac -classpath ../classes -d ../classes -sourcepath . hello_rmi_iiop/*.java completed without any errors

                      Comment

                      Working...