• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Beginner package help please

 
Greenhorn
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!
 
Evildoers! Eat my justice! And this tiny ad's justice too!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic