• 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 ...
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown

Beginner package help please

Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working an example from a book, the topic is on packages. The code listed below compiles fine if "package BookPack" is commented out. If package BookPack is not commented out I get the following pre-compile error: class, interface or enum expected. The book suggests, "create the package directories below your current development directory. Well I think my development directory is the one that contains the .java file I'm working with, in this case that is hsbookdemo.java. The path is listed here: C:\Documents and Settings\DS\My Documents\NetBeansProjects\HSBookDemo\src\hsbookdemo Now, how do I create a package directory? And where is below? Is the package directory placed here: C:\....\HSBookDemo\src\hsbookdemo\bookpackage. Where bookpackage is the package directory.

The book also says, " to put the class files into the appropriate directories". I found class files in this path: C:\....\HSBookDemo\build\classes\hsbookdemo[b] This path has the files: [b] HSBookDemo.rs, HSBookDemo.class, Book.class. The book finally says,"execute the programs from the development directory". Does any of this mean I have to use the command prompt with: java BookPack.BookDemo. If so, I gave up with the command prompt along time ago and downloaded an IDE. I use the NetBeans IDE. The code is listed below:

The output works out fine, I don't think it is needed, but here it is anyway.

Ranch Hand
Posts: 50
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your class is already under the package - hsbookdemo and you already had that in the very first line of your class. so you don't need the second package.

And regarding your question to create new package in IDE just right click on your project name and select new package.

Hope this helps!
I claim this furniture in the name of The Ottoman Empire! You can keep this tiny ad:
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic