I will try to make a long story short but I have done a lot of research on Java and RMI and have all the pieces understood for my example except for the topic of packages and classpath. Obviously, a fundamental Java item I am missing!
I am trying to run and test an RMI example that was in my Mastering RMI book. I read in one document that I don?t need to worry about classpath for application creation or execution (after Java 1.2) if I use Jar files (because if set up correctly the jar files will take care of it). However, I am still having issues just setting the package up to properly JAR it.
I understand the classpath grants visibility to things in a directory system. No problem there. I understand that packages are designed to gather applications together neatly and promote re-use. No problem there.
Based on this, I am assuming that my directory is helloworld\src\main and my package is masteringrmi.helloworld.interfaces because that is how it is specified in my java source files (statement below). Is this assumption correct?
Class #1 package masteringrmi.helloworld.interfaces; public class HelloWorld{}
class #2 package masteringrmi.helloworld.server; import masteringrmi.helloworld.interfaces.HelloWorld; public class HelloWorldImpl{}
I believe most or all of my problem is because of package and class visibility within the environment!
My main problem is I don?t know how to compile and Jar the objects in the above ?package?. If I compile the interface source, it compiles fine. But when I go to compile the server part, it can?t see the interface part I just created. I thought I didn?t have to specify a classpath! Hopefully, you understand my dilemma here. All the package documentation I have seen clarifies the reasons for the path and packaging but I don?t think they are clear on how to utilize them in practice. Can someone walk me through a compile in relation to what directory I should be in, to compile sources in the above directory(s), and what my environment variables should look like to accomplish this. It would also be very helpful to know what the package and directory structure SHOULD look like before and after I am completed so that I know exactly where I am heading with all of this.
> My main problem is I don?t know how to compile and Jar the > objects in the above ?package?. If I compile the > interface source, it compiles fine. But when I go to > compile the server part, it can?t see the interface part I > just created. I thought I didn?t have to specify a > classpath! Hopefully, you understand my dilemma here.
You should probably look at sourcepath while compiling the server part...