I’m trying to compile a Java project (of a Lisp interpreter) in Unix (Solaris to be specific). My problem is that I have a few classes that extend other classes, but when javac attempts to compile the extended classes, it says it can’t find the superclass.
Commands I type:
javac -g LispObject.java
javac -g Sexp.java
The first one works fine; but the second halts with the following error:
Sexp.java:7: Superclass interpreter.LispObject of class interpreter.Sexp not found.
public class Sexp extends LispObject
^
1 error
(I don’t know if it’s very relevant but this is for a class project so I have to use a makefile for the compilation, so I can’t use any IDEs for the compilation… which sucks because everything worked fine in NetBeans.)
Code for LispObject.java:
package interpreter;
public class LispObject extends java.lang.Object
{
// empty
}
Code for Sexp.java:
package interpreter;
public class Sexp extends LispObject
{
// body stuff goes here
}
Try adding
-cp .to yourjavaccalls so that it searches the current directory for already compiled classes. Second call would be:Alternatively, give it all your
.javafiles in one go:Generally the best would be to set up a specific build directory (i’ll call it /some/dir/build) and use:
so that the
.classfiles don’t come polluting your source file directorie(s).Keep in mind that you should keep your directory structure in sync with your package hierarchy. If your classes are in the
interpreterpackage, they should be placed in a directory with that name.So in this specific instance, your compile command should look like: