File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Using Java Bean compiled without a package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Using Java Bean compiled without a package" Watch "Using Java Bean compiled without a package" New topic

Using Java Bean compiled without a package

Salvador Cecilio
Ranch Hand

Joined: Dec 20, 2004
Posts: 41
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 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?

SCJP 1.4 - 93%
SCWCD 1.4 - 89%
IBM FileNet 3.5 - Developer
IBM FileNet 3.5 - Administrator
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

No, I don't think this would work. Anyway, putting everything into packages is good practice, so you should stick to it.

[My Blog]
All roads lead to JavaRanch
Peter Sin
Ranch Hand

Joined: Jan 13, 2005
Posts: 547
Java bean can't be placed without package.
I agree. Here's the link:
subject: Using Java Bean compiled without a package
It's not a secret anymore!