Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't Compile a Class that Implements an Interface?

Status
Not open for further replies.

Phoenix22

Technical User
Sep 23, 2003
29
CA
Hi,

I keep getting an error message when I'm compiling a class that implements an interface:

ToolV1/Calculator.java [14:1] cannot resolve symbol
symbol : class CalculatorInterface
location: package ToolV1

The class I'm trying to compile is as follows:

***********************

package ca.ToolV1;

public class Calculator implements ca.ToolV1.CalculatorInterface {

/** Creates a new instance of Calculator */
public Calculator() {
System.out.println("In Calculator's constructor");
}

public void calculate(String Response) {
System.out.println("About to Calculate");
}

}

***********************************************
It doesn't work when I omit the pkg name and use "implements CalculatorInterface" either. My interface is defined as follows:

*********************

package ca.ToolV1;



public interface CalculatorInterface {

public void calculate(String Response);

}

********************

Any help would be much appreciated, thank you in advance!
 
I copied your code and was able to compile with no problem.

Here are some things to try:
1. make sure you've compiled your interface first (sounds obvious, but you never know)

2. make sure your source is in a directory structure of
- ca
- ToolV1


 
Hi,

Thanks for your reply. I've already done 1 & 2 and my code still doesn't compile. I'm using an IDE (Netbeans) and my class path is set to the package path, ie. ca.

However, I'm still getting the unresolved symbol error message below:

ToolV1/Calculator.java [14:1] cannot resolve symbol
symbol : class CostCalculatorInterface
location: package ToolV1

Any suggestions/advice would be much appreciated, thank you.
 
Set your classpath to the directory above ca. Since ca is part of the fully qualified class name, the compiler will be looking for a class called ca.ToolV1.CostCalculatorInterface and it won't find it in ca, it will find it in the directory immmediately above ca.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top