aspose file tools*
The moose likes Beginning Java and the fly likes on the subject of packaging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "on the subject of packaging" Watch "on the subject of packaging" New topic
Author

on the subject of packaging

colton peterson
Ranch Hand

Joined: Nov 18, 2007
Posts: 97

If you have a package with two classes and one class wants to use the other class do you have to import the package even though they are in the same package?


www.mormon.org
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Nope. They'll both have the same "package x.y.z;" line, of course.


[Jess in Action][AskingGoodQuestions]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

No you don't need to explicitly import it.


[My Blog]
All roads lead to JavaRanch
colton peterson
Ranch Hand

Joined: Nov 18, 2007
Posts: 97

is there any kind of declaration you have to do so that classes in the same package can "see" each other, because I can not compile my class because it can't find my other classes. I have checked the classpath.

Let me guess. The next thing you guys will ask is "Can you post the code" so here it is


and here is the error messages

[ March 30, 2008: Message edited by: colton peterson ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Ref: JLS - 7 Packages...
A package consists of a number of compilation units (�7.3). A compilation unit automatically has access to all types declared in its package and also automatically imports all of the public types declared in the predefined package java.lang.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by colton peterson:
... I have checked the classpath...

What is your classpath set to? Which directory are you compiling from?

ShapeIcon and SyncPoint are both declared to be in the package com.googlepages.kpcode.LynxVsRabbit, right?
[ March 30, 2008: Message edited by: marc weber ]
colton peterson
Ranch Hand

Joined: Nov 18, 2007
Posts: 97

actually I explicitly set it when I compiled I think I still have it somewhere in my command prompt . . .

colton peterson
Ranch Hand

Joined: Nov 18, 2007
Posts: 97

thanks. I got some more errors but they are different than before. Back to debugging!
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

In Java, classes are identified by their qualified names. Because ShapeIcon is in the package com.googlepages.kpcode.LynxVsRabbit, its qualified name is com.googlepages.kpcode.LynxVsRabbit.ShapeIcon, and this is found in the directory C:\Documents and Settings\Kolten\Desktop\lynx vs rabbits\class. Use that as your classpath, and it should work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: on the subject of packaging