aspose file tools*
The moose likes Beginning Java and the fly likes what are java beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what are java beans " Watch "what are java beans " New topic
Author

what are java beans

Maha Hassan
Ranch Hand

Joined: Aug 02, 2005
Posts: 133
i want to know what are java beans or javabeans ..but please in a simple way
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1815
JavaBeans (not to be confused with EnterpriseJavaBeans) are simply a standard way of creating classes to make them friendly to third-party tools. Specifically, a class that is a JavaBean has the following three characteristics:

  • It must have a no-argument constructor.
  • It's exposed member variables are accessed through getXXX and setXXX methods.
  • It implements the Serializable interface


  • The last item (implementing Serializable) is often left out, though, as there are other ways to handle the data (like XML).


    Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
    Sherry Jacob
    Ranch Hand

    Joined: Jun 29, 2005
    Posts: 128
    Originally posted by Maha Aburahma:
    i want to know what are java beans or javabeans ..but please in a simple way


    Well here's an even simpler explanation than what Joel gave.

    JavaBeans are reusable software components (classes) which can be integrated into your application, applets, servlets etc.

    These components have properties and methods. The properties are exposed to the user for customizing. By simply customizing the properties of a Bean, one can make an application behave in the desired way without writing lengthy lines of tedious Java code.

    Hope u get it ?

    Cheers !!


    <strong><br />Cheers !!<br /> <br />Sherry<br /></strong><br />[SCJP 1.4]
    Maha Hassan
    Ranch Hand

    Joined: Aug 02, 2005
    Posts: 133
    thanks alot for your help
    got it
    Philip Heller
    author
    Ranch Hand

    Joined: Oct 24, 2000
    Posts: 119
    Originally posted by Maha Aburahma:
    i want to know what are java beans or javabeans ..but please in a simple way



    The original big idea of beans was that they could be inspected by some kind of IDE (for example a GUI builder). The inspection would be done by reflection, which is one of my favorite Java features. It's possible for a program to find out the names of all the data and methods of a class. In fact, in Java you can call a method on an object if you know its name at run time.

    So imagine a class called JetEngineSimulator. You just bought the code from somewhere, and you want to play with it. Wouldn't it be great if you could check it out, or even build a gui around it and create a useful product, without writing a line of code. The Java people hoped that the marketplace would create what would be called "bean boxes". You could tell a bean box, "please become aware of JetEngineSimulator.class". The bean box would say to itself, "hmm, I see that this class has public methods called and . The Beans naming convention says that I should infer that [/CODE]coolantTemperature[/CODE] is a property that clients of the bean might want to manipulate. I'll create a slider in my gui to let the user control this property.

    The whole idea never quite got off the ground, but it's a wonderful idea and I hope it catches on.

    If you want to learn more about reflection, check out the API page for java.lang.Class, and read up on the getFields() and getMethods() methods.



    -- Phil


    Consultant to SCJP team.<br />Co-designer of SCJD exam.<br />Co-author of "Complete Java 2 Certification Study Guide".<br />Author of "Ground-Up Java".
     
    jQuery in Action, 2nd edition
     
    subject: what are java beans
     
    Similar Threads
    J2EE
    Java Beans
    hello guys java beans 6 is really irritating me
    java Beans Vs java objects
    java beans