Solved

Java beans

Posted on 2004-04-06
8
290 Views
Last Modified: 2010-04-01
I would like to ask how to compile simple java beans.

Do I need to install extra software, add extra info to the classpath?  Attempts to compile it give me error return type required and it points to the constructor of the bean.  

Can someone help?
0
Comment
Question by:11pm
  • 4
  • 3
8 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
no extra software required, you need to include any imported classes in the classpath.
What exactly is the error, and on what code is causing it?
0
 

Author Comment

by:11pm
Comment Utility
This is the code.  Where can I compile beans.  I have a directory called servlet development from which I compile my servlets, but I can't do the same with beans.

Cheers
 

package business;

public class Customer{
      
    private String firstName;
    private String lastName;
    private String address;
    private String city;
    private String postCode;
    private String companyName;
    private String phoneNumber;
    private String faxNumber;
    private String emailAddress;
    private String creditCardType;
    private String creditCardNumber;
    private String creditCardExpirationDate;

    public Customer(){
          
        firstName = "";
        lastName = "";
        address = "";
        city = "";
        postCode = "";
        companyName = "";
        phoneNumber = "";
        faxNumber = "";
        emailAddress = "";
    }

    public User(String first, String last, String address, String city,
                String postCode, String companyName, String phoneNumber,
                String faxNumber, String email){
                      
        firstName = first;
        lastName = last;
        companyName = companyName;
        emailAddress = email;
        this.address = address;
        this.city = city;
        this.postCode = postCode;
        this.phoneNumber = phoneNumber;
        this.faxNumber = faxNumber;
    }

    public void setFirstName(String f){
        firstName = f;
    }
    public String getFirstName()
    { return firstName; }

    public void setLastName(String l){
        lastName = l;
    }
    public String getLastName()
    { return lastName; }
   
    public void setAddress(String a){
        address = a;
    }
    public String getAddress()
    { return address; }
   
    public void setCity(String c){
        city = c;
    }
    public String getCity()
    { return city; }
   
    public void setPostCode(String p){
        postCode = p;
    }
    public String getPostCode()
    { return postCode; }

    public void setCompanyName(String c){
        companyName = c;
    }
    public String getCompanyName()
    { return companyName; }
   
    public void setPhoneNumber(String pn){
        phoneNumber = pn;
    }
    public String getphoneNumber()
    { return phoneNumber; }
   
    public void setFaxNumber(String fn){
        faxNumber = fn;
    }
    public String getFaxNumber()
    { return faxNumber; }
   
      public void setEmailAddress(String e){
        email = e;
    }
    public String getEmailAddress()
    { return email; }

      public void setCreditCardType(String c){
        creditCardType = c;
    }
    public String getCreditCardType()
    { return creditCardType; }

    public void setCreditCardNumber(String n){
        creditCardNumber = n;
    }
    public String getCreditCardNumber()
    { return creditCardNumber; }

    public void setCreditCardExpirationDate(String s){
        creditCardExpirationDate = s;
    }
    public String getCreditCardExpirationDate()
    { return creditCardExpirationDate; }
}
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
> package business;

as your bean is in the business package it needs to be in a directory called business

>     public User(String first, String last, String address, String city,

that should be:

    public Customer(String first, String last, String address, String city,
0
 
LVL 5

Accepted Solution

by:
KarcOrigin earned 30 total points
Comment Utility
Change
public User -> public void User

Moreover you have forgotten to diclare email variable

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:11pm
Comment Utility
Thank you, it obviously worked : )
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
> it obviously worked

but was it what you intended :)
0
 

Author Comment

by:11pm
Comment Utility
>Moreover you have forgotten to diclare email variable

Where exactly?

objects, I was too tired and didn't release that acctually you diserved to get these points.  Your answer made it work. Sorry.

I have been working on this  application already for couple of days in a row.  I created this bean, which compiles and is fine, but now I don't know how to connect it to my system.

What is a use keeping these info in the bean?  

I understand that I add the bean to the session and can retrieve the info at any point, is that true?
But how do i do it from jsp and from servlet?  Is it the same mechanism?
0
 

Author Comment

by:11pm
Comment Utility
And, sorry, I am new here, what does PQA means next to my questions?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now