The Artima Developer Community
Sponsored Link

Java Answers Forum
Serious package misunderstanding!

2 replies on 1 page. Most recent reply: Apr 15, 2003 8:15 AM by Ey?un Nielsen

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Guido

Posts: 38
Nickname: kiethb
Registered: May, 2002

Serious package misunderstanding! Posted: Apr 10, 2003 10:15 AM
Reply to this message Reply
Advertisement
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.

This is the package hierarchy I am using:

C:\helloworld\src\main\masteringrmi\helloworld\interfaces
C:\helloworld\src\ma in\masteringrmi\helloworld\server
C:\helloworld\src\main\masteringrmi\helloworld \client

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.


Ey?un Nielsen

Posts: 3
Nickname: eyun
Registered: Jan, 2003

Re: Serious package misunderstanding! Posted: Apr 15, 2003 8:14 AM
Reply to this message Reply
> 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...

E.g.:

C:\helloworld\src\main\masteringrmi\helloworld\server\>javac -sourcepath C:\helloworld\src\main\masteringrmi\helloworld\interfaces *.java

Ey?un Nielsen

Posts: 3
Nickname: eyun
Registered: Jan, 2003

Re: Serious package misunderstanding! Posted: Apr 15, 2003 8:15 AM
Reply to this message Reply
Ah hmmm... sorry...

C:\helloworld\src\main\masteringrmi\helloworld\server\>javac -sourcepath .; C:\helloworld\src\main\masteringrmi\helloworld\interfaces *.java

Flat View: This topic has 2 replies on 1 page
Topic: iterators Previous Topic   Next Topic Topic: Refactoring Java Code

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use