Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java bean can't be placed without package

 
Krishna Latha Grandhi
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why javaBean can't be placed without package?
 
Ed Ward
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not think it is so much can't as shouldn't. Best practice dictates assigning a package to your classes.
For quick tests, I often create java bean classes with no specific package. Hence, they become part of the default package.
 
Daniel Dalton
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the java language specs:

A type-import-on-demand declaration (�7.5.2) imports all the accessible (�6.6) types of a named type or package as needed. It is a compile time error to import a type from the unnamed package.


See specs

The java code beind the JSP is going to have to do an import for your bean insn't it... and the specs say that an import from the unnamed package is illegal. i.e. all Beans must be in packages.
 
Ed Ward
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clearly, I am not thinking thigs through this morning and just spouting off the first thing that comes to mind.
 
Krishna Latha Grandhi
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Daniel..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic