Colorado State University

Common Java Error Messages



Common Error Messages from the Compiler

While by no means exhaustive, we've listed a few error messages that you might encounter early in the process and suggested some solutions. The list is completely biased by what error messages we have seen in our programming recently :-)
Undefined variable
You've referenced a variable that is not defined within the scope that it is used. Check whether it is a typo or simply defined elsewhere.
Wrong number of arguments in constructor
In trying to create a new object, you've misused the constructor.
Can't make a static reference to nonstatic variable whatever in class yourclass
You probably used a class name where you meant to use an object name.
Variable whatever in class yourclass1 not accessible from class yourclass2
Don't try to directly reference private instance variables.
Undefined variable, class, or package name
Check spelling and capitalization on the name being used. Probably a typo.

Common Run-Time Errors

Again, we'll be keeping track of error messages that we've seen during run-time with suggested solutions.
Can't find class yourclass
You've given java the wrong name for the class file; you're in the wrong directory, or you haven't imported the classes needed by yourclass to run.



Comments: howe@CS.ColoState.EDU
Copyright © 1998: Colorado State University, CS Department. All rights reserved.