• 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
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

package problem

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm working through a tutorial on Sun's website and it has you create one main class and about 6 or so other classes all in a package called divelog. Although I haven't created my own packages before, I understand the concept. So, I have one class like this...

and then my main class that tries to use this class....

When I try to compile the DiveLog.java file, I get an error that divelog.Welcome not found along with all the other classes called in the populateTabbedPane() method of the code when it says new Welcome(), new WebSite(), etc. Can anyone suggest a reason why I can't get this to compile. I've even tried copying all the code for all the classes from the tutorial pages and I still get the same error. Thanks!
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you created a folder called divelog that is under whatever path you have set up? That would be my first guess, is it isn't finding the Welcome.class file in the location it should be.
Jason
 
tyler jones
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have set up a folder called divelog right on my c drive. Do I need to update any files to locate it there?
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tyler,
When you compile start one directory above divelog and use the -d option.
For example, if your directory structure is

and both <code>Welcome.java</code> and <code>Divelog.java</code> are in <code>c:\javadev\divelog</code>; make sure you are in <code>c:\javadev</code> and then compile using

The -d option tells the compiler to put the .class files in the directory matching the package name; it will search for the <code>divelog</code> directory starting from the current directory. If you compile from within the <code>divelog</code> directory itself it will look for another <code>divelog</code> directory below it.
When you run the program, again, start one level above the <code>divelog</code> directory and enter

Hope that helps.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
 
tyler jones
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jane. That worked fine after a bit of tweaking. So, can you explain to me why I couldn't compile from within the package itself? Thanks again.
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tyler,
The compiler expects to find the directories corresponding to the package names below the current directory.
When you start in <code>divelog</code> the compiler will look for another a subdirectory named <code>divelog</code>. For example, it will expect to see

It always searches from the current directory. If you use a classpath it will begin it's search from the last directory in the classpath. For example, if your classpath was <code>x:\dir\divelog</code> it would still look for another subdirectory <code>divelog</code> starting the search at <code>x:\dir\divelog</code>.
Hope that helps.

[This message has been edited by Jane Griscti (edited October 20, 2001).]
reply
    Bookmark Topic Watch Topic
  • New Topic