Solved

Java beans

Posted on 2004-04-06
8
291 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
ID: 10770605
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
ID: 10770974
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
ID: 10771037
> 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
ID: 10771062
Change
public User -> public void User

Moreover you have forgotten to diclare email variable

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:11pm
ID: 10771091
Thank you, it obviously worked : )
0
 
LVL 92

Expert Comment

by:objects
ID: 10771112
> it obviously worked

but was it what you intended :)
0
 

Author Comment

by:11pm
ID: 10822683
>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
ID: 10822694
And, sorry, I am new here, what does PQA means next to my questions?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: This is the second blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   Every month t…
Note: This is the third blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   We’ve been talki…
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.

932 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

10 Experts available now in Live!

Get 1:1 Help Now