Java compile problem

  • 13 years ago
    I have been trying to compile a java bean using javac from within Fedora Linux 5.  I compiled the first bean creating a class succesfully but the second keeps on coming up with an error.  Both java files are stored in WEB-INF/classes/beans

    Here is my code:





    //ItemOrder.java

    //file location /WEB-INF/classes/awpica

    package beans;

    public class ItemOrder implements java.io.Serializable{

        private String name;

    //constructor
        public ItemOrder() {
            name = null;       
        }

    //accessors
        public String getName(){return name;}
        public void setName(String s){name = s;}

        public boolean isValid()
        {
            if ( ( name != null) )
                return true;
            else
                return false;
        }

    //end of class ItemOrder
    }

    ---------------------------------------------------------------------
    //BikeOrder.java

    //file location /WEB-INF/classes/beans
    package beans;

    import java.util.ArrayList;

    public class BikeOrder implements java.io.Serializable{

    //instance variable
        private ArrayList cart;


    //constructor
        public BikeOrder() {   
            if (cart == null)
                cart = new ArrayList();
        }

        public void setItem(ItemOrder o){cart.add(o);}
        public ArrayList getCart(){return cart;}

    //end of class
    }

    When comiling the bike order the following error is produced -
    ItemOrder cannot be resolved to a type

    Many Thanks




























































  • 13 years ago
    You must use templates.

    If ItemOrder.java is in other package import this package in BikeOrder, and change the following:

    private ArrayList cart;

    to

    private ArrayList ItemOrder cart;

    where ItemOrder is parameter of template, I DIDN'T MANAGE TO WRITE THIS SIGNS - < .Of course change the constructor of BikeOrder either

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why.”