We are independent & ad-supported. We may earn a commission for purchases made through our links.
Advertiser Disclosure
Our website is an independent, advertising-supported platform. We provide our content free of charge to our readers, and to keep it that way, we rely on revenue generated through advertisements and affiliate partnerships. This means that when you click on certain links on our site and make a purchase, we may earn a commission. Learn more.
How We Make Money
We sustain our operations through affiliate commissions and advertising. If you click on an affiliate link and make a purchase, we may receive a commission from the merchant at no additional cost to you. We also display advertisements on our website, which help generate revenue to support our work and keep our content free for readers. Our editorial team operates independently of our advertising and affiliate partnerships to ensure that our content remains unbiased and focused on providing you with the best information and recommendations based on thorough research and honest evaluations. To remain transparent, we’ve provided a list of our current affiliate partners here.
Software

Our Promise to you

Founded in 2002, our company has been a trusted resource for readers seeking informative and engaging content. Our dedication to quality remains unwavering—and will never change. We follow a strict editorial policy, ensuring that our content is authored by highly qualified professionals and edited by subject matter experts. This guarantees that everything we publish is objective, accurate, and trustworthy.

Over the years, we've refined our approach to cover a wide range of topics, providing readers with reliable and practical advice to enhance their knowledge and skills. That's why millions of readers turn to us each year. Join us in celebrating the joy of learning, guided by standards you can trust.

What are JavaBeans™?

By Emma G.
Updated: May 17, 2024
Views: 9,604
Share

JavaBeans are reusable software components, or sections of code, for programs written in the Java® language. They are designed to allow programmers to write a program once and run it on any system. The same JavaBeans can be used to create many different programs. In order to remain portable, JavaBeans must follow certain programming conventions.

The Java® programming language was developed in the mid-1990s by James Goseling at Sun Microsystems. The syntax is similar to that of the C and C++ programming languages. It differs from these languages because the object model is simpler. The great advantage to the Java® language is that programs written in Java® can run on any computer system without changes to the code.

JavaBeans™ help Java® programs to remain portable. They are basically a number of objects grouped together so that they can be moved as a group instead of individually. To achieve this, JavaBeans™ follow certain conventions in naming, construction, and behavior.

A JavaBean™ must be able to be serialized. This means it can be converted into a sequence of bits so it can be stored in a file or transmitted across a network. Other names for this process are deflating and marshalizing. To use the JavaBean™ after it has been serialized, it must be reconstituted in a process called deserializing or inflating.

Another convention used in writing JavaBeans™ is the nullary constructor. A constructor is a subroutine, or sequence of events, called at the creation of an object to prepare the object for use. Constructors normally accept parameters to set the variables of the object. A nullary constructor accepts no parameters.

To protect against accidental or code damaging changes to variables, variables in JavaBeans™ are set to private. This means that they are accessible only to functions that are a member of the same class or to those that are granted specific access. They can only be modified using a public member function, which takes the new value as a parameter and then modifies the private variable. A similar subroutine can return the value of the private member variable to the code writer. This is called the getter and setter method or the mutator method.

JavaBeans™ should not be confused with Applets. Applets are miniature, web-based programs, while JavaBeans™ are reusable components that can be put together to make programs. In some cases, Applets can be designed to fulfill similar functions to JavaBeans™.

Share
WiseGeek is dedicated to providing accurate and trustworthy information. We carefully select reputable sources and employ a rigorous fact-checking process to maintain the highest standards. To learn more about our commitment to accuracy, read our editorial process.

Editors' Picks

Discussion Comments
By WaterSerpent — On Oct 28, 2014

I'm just learning to write code using an online free website. Until I started, I would have thought Java Beans were from Columbia and packed with caffeine. Ha-ha.

Seriously though, the article mentions that Javabeans can only be accessed with specific access or a public member function to prevent accidental or damaging changes. Is there any way to get around that if you want to change a program on your own computer?

Share
https://www.wisegeek.net/what-are-javabeans.htm
Copy this link
WiseGeek, in your inbox

Our latest articles, guides, and more, delivered daily.

WiseGeek, in your inbox

Our latest articles, guides, and more, delivered daily.