• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Java Bean compiled without a package

 
Salvador Cecilio
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • 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?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Peter Sin
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java bean can't be placed without package.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic