File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

classes in package cannot see other classes in same package

 
k Oyedeji
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have the following as part of my classpath:
c:\javatemp
in the javatemp folder i have a folder called rental. Every java file in rental has as the first line so this should be enough for all the classes to be part of the rental package. However when i try to create an object of for example class Car i get a class not found error this is despite the line
Have i missed something, I recently added to my classpath, i'm using windows 2000, should the addition to my classpath be immeidiate or do i need to reboot/login-logout?
Any ideas why the classes cannot see each other (but compile) they are also all public
Thanks
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a little confused: is the "import rental.Car" in a class in the rental package itself? It's definitely not necessary, in that case, and I'm not altogether sure it's allowed.
Note that you'll have problems if "rental" is your current directory when you're compiling; you want to compile things from the javatemp directory, like "javac rental\*.java" .

i'm using windows 2000, should the addition to my classpath be immeidiate or do i need to reboot/login-logout?

If you made this addition to your CLASSPATH via the control panel, then it should take affect for any console windows opened after the change is made, but not for those that were already open. Otherwise it sounds like you're doing the right things.
[ August 26, 2003: Message edited by: Ernest Friedman-Hill ]
 
Joel McNary
Bartender
Posts: 1824
Eclipse IDE Java Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EFH: I'm a little confused: is the "import rental.Car" in a class in the rental package itself? It's definitely not necessary, in that case, and I'm not altogether sure it's allowed.
I agree that it's not necessary, since you don't need to qualify classes in the same package, but it is allowed. (I just tested it )
EFH: Note that you'll have problems if "rental" is your current directory when you're compiling; you want to compile things from the javatemp directory, like "javac rental\*.java" .
As long as C:\javatemp is in the classpath, there should be no problems compiling from the "rental" directory. I do this sort of thing all the time.

Anyway, as Ernest suggested, try closing the console window and opening a new one to see if that solves the problem. If it doesn't, please cut-and-paste the exact error that you are getting so that we can all see it -- that will greatly aid our diagnosing the problem.
Thanks.
 
k Oyedeji
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys
Thanks for the replies. I did think that the import was unneccesary as the classes are all in the same package. I have since removed the import statement. I rebooted my PC over night and I still get the following error:

which points to the following line in rentalCentre.java:-

I've double checked Vehicle and it is definetly part of the same package, I've also double checked my classpath and it appears to be okay. DOes the above line seem okay?
THanks
 
k Oyedeji
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay
I've just noticed that when i compile it inside JBuilder -classpath switch does not include the folder i added to the classpath does this mean that when using this switch, any packages which are part of the current classpath are ignored and only the ones which follow the switch are used?
I compiled it outside JBuilder and i get different error messages (but it does recognise the classes) so i'm thinking this is the problem.
Thanks guys for your help
 
Joel McNary
Bartender
Posts: 1824
Eclipse IDE Java Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is indeed the problem: the -classpath switch overrides the system CLASSPATH.
If you have difficulties with any of your other problems, just let us know. We're glad to help.
 
k Oyedeji
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the input, i guess my only other question is does anyone know how to specify what is included in the classpath switch when compiling using JBuilder

Thanks
 
Joel McNary
Bartender
Posts: 1824
Eclipse IDE Java Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure -- I don't use JBuilder myself. You might try posting that question in the IDE's and other tools forum; you'll probably get a better response.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does anyone know how to specify what is included in the classpath switch when compiling using JBuilder
Project -> Project Properties... -> Path Tab -> Required Libraries Tab -> Use the Add... button to your heart's content.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic