?
Solved

Java beans

Posted on 2004-04-06
8
Medium Priority
?
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Accepted Solution

by:
KarcOrigin earned 120 total points
ID: 10771062
Change
public User -> public void User

Moreover you have forgotten to diclare email variable

0
 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hey fellow admins! This time, I have a little fairy tale for you. As many tales do, it starts boring and then gets pretty gory. I hope you like it. TL;DR: It is about an important security matter, you should read it if you run or administer Windows …
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

752 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