I am trying to compile my program on a Unix machine per my instructor's directions. I am getting two errors when I compile my interface. The two errors are

cannot find symbol
symbol: class OverFlowException
location: interface Ch3Pkg.PracticeCollection<E>
public void add<E element> throws OverFlowException;

cannot find symbol
symbol: class ElementMissingException
location: interface Ch3Pkg.PracticeCollection<E>
public E remove<E element> throws ElementMissingException;


So the program runs fine in Eclipse and Net Beans, however when I try to compile using command prompt or the Unix machines, I get these errors. Its driving me crazy. I have compiled the two classes above first, and they compiled without any errors just fine. I have posted the interface, and the two exception classes below. Thanks in advance for your help.

INTERFACE CODE:

package Ch3Pkg;


// Defines an interface of common operations on a container.
public interface PracticeCollection<E>
{
   public static final int DEFAULT_CAPACITY = 20;

   // Throws an OverflowException if the collection is full.
   // Otherwise, adds element to the collection.
   public void add(E element) throws OverFlowException;

   // Throws an ElementMissingException if element is not in collection.
   // Otherwise, removes element from the collection and returns it.
   public E remove(E element) throws ElementMissingException;


   // Returns the number of elements in the collection.
   public int size();


   // Prints elements in the collection to the standard output,
   // one element per line.
   public void print();
}

MISSING ELEMENT EXCEPTION CODE:

package Ch3Pkg;

public class ElementMissingException extends RuntimeException
{
	public ElementMissingException()
	{
		super();
	}
	public ElementMissingException(final String msg)
	{
		super(" " + msg);
	}
}

OVER FLOW EXCEPTION CODE:

package Ch3Pkg;

public class OverFlowException extends RuntimeException
{
	public OverFlowException()
	{
		super();
	}
	public OverFlowException(final String msg)
	{
		super(" " + msg);
	}
	
}

Did you compile those two exception classes before compiling the other and did you use "-cp ." on the command line?

Also, why extend RuntimeException and then declare the methods to throw those exceptions? RuntimeExceptions are unchecked excpetions, they are not suppossed to be caught (although they can be), and they are definately not meant to be declared to be thrown.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.