• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
Bartenders:
  • Himai Minh
  • Carey Brown
  • Frits Walraven

Packages

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand why when i create package from the same folder as my main source file the package is not seen. But when i create my package form a folder in another directory than the main source file it's working fine. ex:
folder1, main.java, test1.java. When i compile javac -d . test1.java to create package testPackage ,i cannot access test1.class with import testPackage.*; as javac main.java.If i have test1.java in folder2 and i compile the same way
javac -d .. test1.java now it compile main.java with the import testPackage.* correctly
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your folder name needs to be same as your package name... do you have that?
Try checking out this thread for more information:
Problem importing class
[ June 11, 2002: Message edited by: Jessica Sant ]
 
Francois Boisvert
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok here again....

4-from f:\MailBox
i compile javac MailBoxTest.java
// this works fine

5-Now when i create the package from f:\MailBox
the same way ... javac -d . Message.java
javac -d . MailBox.java etc...
the line javac MailBoxTest.java now gives me error
that is

the same error for all other classes in package.
Message.java...looks like this...

MailBox.java...

MailBoxTest.java...Now this one don't work anymore

Obviously using
import cdi.message.MailBox;
will work , but not with the wild card *
???
i am again puzzled......;-)
[ June 11, 2002: Message edited by: Dirk Schreckmann ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jessica had mentioned it, but then the weirdo deleted her post. So, I'll mention it...
Francois, in order to preserve formatting, you can wrap the text with the [code] and [/code] UBB tags.
 
Francois Boisvert
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok (sorry) me again
if i put all my java file for the package like this
1- from f:\mailbox

and i store my java files for the package in mailbox directory and create my package from f:\mailbox directory
javac -d . Message.java
javac -classpath . -d . MailBox.java
javac -classpath . -d . TextMessage.java
javac -classpath . -d . VoiceMessage.java
javac -classpath . -d . Console.java
i get the same tree structure as mentioned above
as in the previous post message.
But compiling
javac MialBoxTest.java do not go , it looks like if i have the java file for the package in the same directory as my MailBoxtest.java ,it seem to interfere while compiling???

[ June 11, 2002: Message edited by: Francois Boisvert ]
[ June 11, 2002: Message edited by: Francois Boisvert ]
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like MailBoxTest.java belongs to the default package (it contains no import statement). So you have to put MailBoxTest.java in the MailBox directory, and the rest into MailBox/cdi/message.
 
Francois Boisvert
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes your are right, MailBoxTest belong to default package, but my main concern is to understand why the compiling do not go properly when i have my java source files for my package in the same directory(mailbox) as my main application MailBoxTest.java. This does not happen when my java files for my package are outside of mailbox directory.It is just a matter of moving them in a different directory...without recompiling the package files.It compile ok using import cdi.message.*
It seem that the resolution for package/class naming is not ok , i frankly have difficulty to undersand why?
 
reply
    Bookmark Topic Watch Topic
  • New Topic