• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Using Java Bean compiled without a package

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been able to create and use java beans only if they are part of a package.

I'm reading the SCWCD Exam Book by Manning Publishing and their example code doesn't work on my machine (Tomcat Standalone 4.1.31). Specifically the example of usage of Java Beans in Chapter 14 (pages 251-252). The following code causes an error:



The AddressBean.java file is as follows:



I can get the java bean to work if I compiled it as part of a package and use the import statement.

Is it possible for a java bean to be compiled without a designation to a package and still be used?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I don't think this would work. Anyway, putting everything into packages is good practice, so you should stick to it.
 
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java bean can't be placed without package.
 
reply
    Bookmark Topic Watch Topic
  • New Topic