I’m trying to compile a class Tmp that implements an interface TmpInter.
/* Interface */
package test;
public interface TmpInter {
public void show(String s);
}
/* Class */
package test;
public class Tmp extends TmpInter {
public void show(String s) {
System.out.println("hello");
}
}
Now when I’m trying to compile the class Tmp.java I’m getting the error
D:\java\rmi\Hello>javac TmpInter.jav
D:\java\rmi\Hello>javac Tmp.java
Tmp.java:3: cannot find symbol
symbol: class TmpInter
public class Tmp extends TmpInter
^
I went through all the similar posts and tried those solutions but, in vain.
I’m saving and running both the files in the same directory and the .class files are being generated in the same folder. I tried the -classpath option as well but didn’t work. I’m compiling these files from the windows cmd when tried in Eclipse it is working fine. Also I tried compiling all the files at a time in that folder using javac *.java this is generating all the required .class files without any error but iam unable to figure out why this is not so when compiled individually.
Besides what Binyamin said, make sure that the current directory is in the classpath. Try compiling like this:
(Run this from the directory that contains the
testpackage directory).The
-cpoption sets the classpath..means “the current directory”. Normally, if you do not have theCLASSPATHenvironment variable set, the current directory is automatically in the classpath. But if you’ve setCLASSPATHand didn’t add the current directory explicitly, it won’t work.