File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes whats a java bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "whats a java bean" Watch "whats a java bean" New topic
Author

whats a java bean

Leonardo Go
Greenhorn

Joined: Jun 13, 2004
Posts: 13
hello im really a newbie and im a bit confused.
whats a java bean and how can i create one?
also how do i use it?
whats the advantages of using this ?

thnx a lot


Problems are made to be solved.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Moving to the Java in General(intermediate) forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vijay Vaddem
Ranch Hand

Joined: Feb 13, 2004
Posts: 243
Hi,

A Java Bean is a software component written in the Java programming language that conforms to the JavaBeans component specification.


we use beans for server side interaction. In a typical web application,
the bean is the model, JSP is the view and Servlet is the controller.

The bean contains data and is stored via the session mechanism. Multiple Webpages (JSP/Servlets) can access and modify the bean.

Any class with a set of properties and corresponding getter and setter methods can be called as a bean.

Vijay
Vijayendra V Rao
Ranch Hand

Joined: Jul 04, 2004
Posts: 195
Hi Vijay,

Were you talking about JavaBeans or EJB?


Vijayendra <br /> <br />"The harder you train in peace, the lesser you bleed in war"
Leonardo Go
Greenhorn

Joined: Jun 13, 2004
Posts: 13
so you mean to say that a bean is just a new name for a class.
when you make application programs in java but do not intent to use it in web can i call that class a bean ?
or a class can be called a bean only if im doin web apps ?
and whats the use of a bean ?
can you send me a sample project using beans ?

thnx in advance
Vijayendra V Rao
Ranch Hand

Joined: Jul 04, 2004
Posts: 195
Originally posted by Leonardo Jr Go:

can you send me a sample project using beans ?



Hi Leo,

I think you should go through the EJB explanation in the J2EE turorials. I think this will help you a lot in clarifying many of your doubts.
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1704
Yeah Java Bean is nothing but a Java class and its a resusable component satisfying 3 conditions as per Sun specification.

1. A JavaBean need to be persistent. For that all JavaBean Classes need to implement Serialization.

2. Dyanamic Instantiated: Each JavaBean can be dyanamically instantiated. For this we provide a default constructor or no constructors at all.

3. Introspection: We will make all properties as private and provide mutator methods(set and get methods) to operate on those private properties.

The major difference between EJB and JavaBeans is EJB are distrubatable components. The idea behind developing EJBs is two applications running on different JVMs can talk each other. Where as JavaBeans are just resuable components.

I hope you got some idea now.

Regards
Jagdish
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Strictly a "JavaBean" is a concept created primarily for GUI building. The specification is here.

Since this the idea of a JavaBean was co-opted by the J2EE spec. people to describe a class which behaves roughly in the way Jagdish Reddy describes it. Except that the J2EE specification only mentions Enterprise Java Beans, and makes no mention of JavaBeans.

I tell you this because without knowing of the existance of the earlier definition, some documentation can be very confusing.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
and of course some J2EE people will muddy the waters further by referring to EJB as beans when really they are nothing of the kind.


42
Vijayendra V Rao
Ranch Hand

Joined: Jul 04, 2004
Posts: 195
Originally posted by Jeroen Wenting:
and of course some J2EE people will muddy the waters further by referring to EJB as beans when really they are nothing of the kind.


Precisely! EJB and Java Beans are no way similar to each other.
Leonardo Go
Greenhorn

Joined: Jun 13, 2004
Posts: 13
Originally posted by Vijayendra V Rao:


Precisely! EJB and Java Beans are no way similar to each other.


ok.. will you please tell what is ejb?

and my problem is i dont know where to start learning because i dont have anything to solve yet since i want to learn by making a project..

can you please send me a small project just to start with..
thnx in advance..
my mail is lordango@yahoo.com
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You can get an example project from Sun - look for the J2EE tutorial (which is also a good idea since it will help you understand what an EJB is).

To get you going - an Enterprise Java Bean is a component intended to be deployed in an EJB Container, which is used specifically for the purpose of developing so-called "Enterprise" applications. "Enterprise" is a bit of a marketing terms which is probably best summarised as: large, distributed applications. An EJB relies on the container's services to run. The container supplies services commonly needed by Enterprise applications, such as Transactions, clustering, security etc.

If you want to learn EJBs the best place to start is the tutorial link above. There are a whole raft of resource on the web too. Have a look at the documentation for a couple of the big Containers: Bea Weblogic,IBM WebSphere and JBoss. Bea's documentation in particular is pretty good. Also keep an eye on the EJB forum here - a lot of commonnproblems (and good answers) turn up in there.
[ August 06, 2004: Message edited by: Paul Sturrock ]
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Hi Leonardo,

Are you a newbie to Java or just to J2EE (Java 2 Enterprise Edition, which includes advanced stuff like Enterprise JavaBeans - EJB)?

If you're new to Java then I would suggest learning the basics of the language, say with some of the exercises from this site or from Sun's site.

If it's J2EE and EJB you want to learn then take Paul's advice.

Jules
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: whats a java bean