Compiler Error Messages | |
---|---|
Key | What Compiler Says |
Real Error / Possible Causes | |
( expected | ( expected instead of {. |
// oops missing [] in attempt to define an array literal new String { "x", "y" };instead // how to create string array literal new String[] { "x", "y" };See balancing. | |
. expected | '.' expected. Usually pointing to an import statement. |
You must import either a packagename.* or packagename. Classname. You can’t just import packagename or import Classname. You don’t import classes in the same package as the current class. In other words, the thing you import will always contain at least one .. You don’t use import for code not in any package. You have to put such classes on the classpath. Whenever you have more than one class, it is a good idea to assign every class to an explicit package with a package statement. In summary, you import fully qualified classes, with package and classname separated by a dot. You don’t import classes without packages. | |
.class expected | '.class’ expected |
you wrote int i where you meant just plain i. | |
; expected | semicolon expected. |
| |
; missing | ';' expected. 'else' without if. statement expected. invalid expression. |
missing semicolon. See ; expected. | |
= expected | = expected. |
Look for a stray } just before where it is complaining. | |
[ expected | Missing [ |
Likely you wrote [i,j] instead of [i][j]. | |
already defined | Variable 'x' is already defined in this method. |
duplicate variable declaration | |
ambiguous class | ambiguous class x.y.SomeClass and a.b.SomeClass, reference to Object is ambiguous, both class org.omg.CORBA.Object in org.omg.CORBA and class java.lang.Object in java.lang match. |
// Ambiguous Class import. // If you were to use SomeClass, which one did you mean? import x.y.SomeClass; import a.b.SomeClass;can // Ambiguous Class import for x.y.SomeClass and a.b.SomeClass // but the compiler won't mind unless you actually use SomeClass. import x.y.*; import a.b.*;Some compilers may complain about the clash in SomeClass, even if you never reference it. And, of course, all references to SomeClass should be disambiguated to either x.y.SomeClass or a.b.SomeClass. Alternatively, you can throw out all the imports and fully qualify all classes in x.y and a.b. This approach makes code easier to maintain because it is easier to find the code that implements the class when it is fully qualified. In your own classes, try to use globally unique class names. Even if the computer understands the ambiguity, humans often become confused. | |
array not initialised | Array a may not have been initialized. |
You forgot to initialise an array with new int[5]. | |
attempt to reference | Attempt to reference method xxx in class XXX as an instance variable. |
missing dummy pair of parentheses after the 0-argument method name. | |
attempt to rename | jarsigner: attempt to rename xxx.jar to xxx.jar.orig failed. |
Your jar is in use by some running Applet or application. Shut it down to build and sign the jar. | |
bad class file | bad class file: XXX.java file does not contain class XXX. Please remove or make sure it appears in the correct subdirectory of the classpath. |
Check that the package statement and the class statement have names that are precisely correct including case and that this file is in a directory that precisely matches the package name and the source file name that precisely matches the class name followed by .java. | |
blank final | Blank final variable 'xxx' may not have been initialized. It must be assigned a value in an initialiser, or in every constructor. |
Check that your final variable is indeed so initialised. If it is, remove the final, to bypass a bug in the Javac 1.1 compiler. | |
Boolean dereferenced | Boolean cannot be dereferenced. |
You need extra layers of parentheses around your casting. | |
Bound mismatch | Eclipse error: Bound mismatch: The generic method sort(List<T>) of type Collections is not applicable for the arguments (ArrayList<X>). The inferred type X is not a valid substitute for the bounded parameter <T extends Comparable<? super T>> |
You forget to implement Comparable on the class X you are sorting. | |
can’t access class | Can’t access com.mindprod.mypackage.MyClass. Only classes and interfaces in other packages can be accessed. |
| |
can’t be applied | setVisible(Boolean) in java.awt. Component cannot be applied to () |
You wrote x.setVisible()
instead of x. setVisible(
true ), or similar parameter mismatch.
Check the types of parameters and arguments for an exact match. Whenever you
see cannot be applied check the Javadoc to make
sure the signature of the method you are calling matches the types of the
arguments. The problem often is you are sure a method must logically have to
exist that does not.
It ain’t what you don’t know that gets you into trouble. It’s what you know for sure that just ain’t so. | |
can’t be dereferenced | int cannot be dereferenced. |
You need extra layers of parentheses around your casting. or perhaps you may have written something like i.toString() where i is an int rather than an object with methods. You need to write something like Integer.toString( i) instead. ints can’t have any instance methods. They can be parameters to either static or instance methods though. | |
can’t be instantiated; | load: com.mindprod.mypackage.MyApplet.class can’t be instantiated. java.lang.InstantiationException: com/mindprod/mypackage/MyApplet |
You are missing the default constructor for your Applet. See The Case of the Disappearing Constructors. | |
can’t convert from Object to X | Type mismatch: cannot convert from Object to X. |
This error often comes up in the context of the clone method which, without covariance, returns an Object reference not the specific type of the Object cloned as you might naïvely expect. You tried to use a general Object reference in a context that requires something more specific. Sometimes all you need is a cast. | |
can’t determine application home | Can’t determine application home. |
Uninstall all Java JDKs (Java Development Kits) and JREs (Java Runtime Environments) with the Control Panel. Use Microsoft’s RegClean. Tidy up the registry with regedit. Reinstall just the latest JDK (Java Development Kit). | |
cannot find symbol | Cannot find symbol |
You used a variable name you did not define. Perhaps you forgot the
declaration. Perhaps you declared it inside a block/loop and you tried to use
it outside the block/loop. You must move the declaration to an encompassing
outer block that encloses all the references. Perhaps you spelled the
variable slightly differently in declaration and reference. Watch your caps
and double letters carefully. Perhaps you left out or mistyped the
corresponding import or static import.
Cannot find symbol constructor XXX, means you likely you did an explicit XXX() to call the superclass constructor first thing in your constructor instead of using super(). Cannot find symbol method XXX, where XXX is your class’s superclass constructor means you likely you did an explicit XXX() to call the superclass constructor first thing in your constructor instead of using super(). Possible causes of the error for constructors and methods:
| |
can’t instantiate abstract class | Error: MyClass is an abstract class. It can’t be instantiated. |
missing method to fulfill an interface implementation | |
can’t make static reference | Can’t make a static reference to non-static (instance) variable x in MyClass. |
using an instance variable in a static method | |
cannot override | toString() in xxx cannot override toString() in java.lang.Object; attempting to assign weaker access privileges; was public. |
You can override a default or protected method with a public one, but not the reverse. | |
cannot override | toString() in xxx cannot override toString() in java.lang.Object; overridden method does not throw java.io.IOException |
Overridden methods cannot add any throws clauses not in the base method they are overriding. | |
cannot override | cannot override xxx() in java.lang.Object; attempting to use incompatible return type. |
When you override an existing method, you must use exactly the same method signature including return type. Perhaps you did not realise you were overriding a method. In Java version 1.5 or later, you may return a subclass of the base return type. | |
cannot resolve constructor | Cannot resolve constructor xxx(). |
If a subclasses constructor does not call one of the constructors of the superclass as the very first thing, java inserts a call to the default constructor for you super(). If you have not defined that null constructor, you will get an error. The usual way to fix it is by inserting some sort of super( parm ); as the first statement of your subclass constructor. See also hints on resolving symbols. | |
cannot resolve symbol | Cannot resolve symbol |
| |
cannot resolve symbol constructor Thread | cannot resolve symbol constructor Thread( YourRunnable ) |
You forgot to write implements Runnable on the class with the run method. | |
cannot resolve symbol this | Cannot resolve symbol this.xxx |
You are inside an anonymous inner class and xxx is a member or method of the enclosing class. You must use Outer. this. xxx instead of this.xxx. | |
cannot use operator new | Cannot use operator new for this type |
You can’t instantiate references, class names as Strings, interfaces or abstract classes, only concrete class names. Perhaps there is no suitable constructor. Perhaps you inadvertently wrote methods instead of constructors by specifying a return type on them. | |
can’t delete jar file | Ant complains it cannot delete the jar file during a build |
You are running the application from the old jar. Shut it down before rebuilding. | |
char cannot be dereferenced | char cannot be dereferenced |
You have tried to use a String or other Object method on a char or char[] which have no instance methods. | |
clashes with package | XXX clashes with package of same name |
Rename your class or rename your package so they don’t have the same name. Usually this is not a problem since package names normally have dots in them. | |
class has wrong version | class file has wrong version 49.0, should be 48.0 |
You are compiling with the Java version 1.4 compiler, referencing class files compiled with the newer Java version 1.5 compiler. The referenced class files must be recompiled with 1.4 to make them compatible with the old Java. Alternatively, you must use JDK 1.5 for everything. | |
class must be defined in a file | Warning: ublic MyClass must be defined in a file called 'MyClass.java'. |
| |
class names only accepted for annotation processing | Error: Class names, 'XXX', are only accepted if annotation processing is explicitly requested |
There is nothing wrong with the text of your program; the problem is in how you tried to compile it. You left off the *.java extension when compiling with javac.exe, e.g. at the command line you typed: javac.exe MyClass
instead of: javac.exe MyClass.java
This is one of the most maliciously misleading of all error messages. | |
class names unchecked only accepted for annotation processing | error: Class names, "unchecked", are only accepted if annotation processing is explicitly requested |
For Netbeans, uncheck the project’s property entitled Enable Annotation Processing in Editor, leaving all others checked on that page and clean and build the project. | |
class not found | Class not found |
This can occur at compile or run time.
| |
class not found in import | class com.mindprod.mypackage.Myclass not found in an import |
All class files and packages you reference in import statements must be accessible via the CLASSPATH, or be part of the project or live in the ext directory. You must import a class, not a package, e.g. import java.io.File ; not import java.io; You can import all the classes in a package with: import java.io. *; It is easiest to use an IDE (Integrated Development Environment) like IntelliJ that inserts and prunes the imports for you. Also remember that package and class names are case-sensitive. | |
class not found in type declaration | Class WindowAdapter not found in type declaration. |
You forgot to import java.awt.event.* or to fully qualify java.awt.event.WindowAdapter. I’m sure you can generalise for other classes. | |
class expected | class expected. |
It is not expecting the keyword class, but rather the name of a class. You might have written something like long.MAX_VALUE instead of Long.MAX_VALUE. | |
class or interface (or enum) declaration expected | class or interface (or enum) declaration expected. |
| |
class, enum or interface expected | class, enum or interface expected |
There is a missing { somewhere much earlier in the code. class and interface must be all lower case. Another way of looking at it, you method and variable definitions come after class, not package. | |
class should be declared in file | class XXX is public, should be declared in a file named XXX.java |
The name of the *.java file must precisely match the name of the public class it defines. The name is case-sensitive. | |
classname not enclosing class | classname is not an enclosing class |
| |
Comparable cannot be inherited | Comparable cannot be inherited with different arguments |
// base class class SalesTaxItem implements Comparable<SalesTaxItem> { ... } The best way I know of to bypass the problem is to write both classes without the implements Comparable. Then write two Comparators instead. | |
duplicate class | Duplicate class |
You misspelled the package name on the package statement. It must match the name of the directory containing the Java source. | |
duplicate methods | duplicate method declaration |
You have two methods with the same name and the same signature i.e. number and types of parameters. You can’t have two methods that differ only in return type. | |
enum as identifier | try -source 1.4 or lower to use 'enum' as an identifier. |
Starting with Java version 1.5, enum became a reserved keyword. Older programs may have used the word enum as a variable, method or package name. You will have to globally rename enum to some other identifier, or convert the code to use the new built-in enum features. | |
error while writing | error while writing <classname>. The system cannot find the path specified. |
You used the javac.exe -d option. The compiler is trying to write the generated class files to this directory, but it cannot, probably because it does not exist. The compiler wants to create a tree of package names in that directory. You may have it blocked by files of the same name as the packages. Use lower case for all package names and directories. | |
Exception never thrown | Exception IOException is never thrown in the body of the corresponding try statement. |
You are trying to catch an exception that could never happen. Just remove the try/catch. Java does not like you trying to catch an exception that could never happen, but oddly it does not mind you declaring a throws that could never happen. | |
final parameter xxx may not be assigned | Attempt to assign to a variable declared as final |
The wording is ambiguous. You might think it means the parameter might, under some circumstances, escape being assigned. That is not what it means. | |
generic array creation | Attempt to create an array of generic objects |
You might have written new ArrayList <String>[ 100] instead of new ArrayList< String>( 100); To be charitable, Java’s generics are Mickey Mouse. One of the side effects of the el-cheapo implementation is that you can’t have arrays of generic collections, e. g. the following is illegal | |
identifier expected | identifier expected |
Look for a missing { slightly before of where it is complaining. It may also be a } before the code that should appear after. It can also be caused by attempting to define a constructor in an interface. Perhaps you wrote some initialisation code without enclosing it in static {} or plain {}. Method calls must be inside methods or init blocks, not just lying loose in amongst the field declarations. | |
illegal character | illegal character: \8220 or \8221 |
You used Unicode 8220 (aka \u291c, 0x291c, “, left quote) or 8821 (aka \u291d, 0x291d, ”, right quote) instead of a simple 34 (aka \u0022, 0x22, ") that Java requires. This probably resulted from using a word processor like MS Word instead of a text processor or IDE to compose your Java source which converts "s into and . | |
illegal escape | illegal escape character |
Mostly likely you forget to double each \ in a filename String, e. g. you should write C:\\temp\\somefile.txt not C:\temp\somefile.txt. Backslash \ has special meaning inside Strings, e. g. \n means newline, \t means tab, \" means embedded ". \\ means a single \. If you used \ followed by a letter without special meaning, you will get this error message. | |
illegal forward reference | Probable forward enum reference |
Java computes its static initialisation in a simplistic top to bottom way. It is not clever, in using natural order like a spreadsheet. Any value you reference must be defined lexically earlier in the class. This holds both for the order of initialisations and for the order of assignments in a static init or instance init block.
| |
illegal reference to static | illegal reference to static field from initialiser |
enum constructors cannot access the
enum static
fields. However, they can invoke the enum’s static methods
that access the static fields, but they
won’t get the right values. The easiest way out is to convert your
static constants to instance constants.
Strange as it seems, they are initialised before the
constructor code. Constructors may, however, directly access static final in-lineable constants known at compile time. The problem is static initialisation has
not been done at the time the enum constructor
constant constructors are invoked, so static
methods called from your constructors will just see zeros/nulls. Why this
screwy rule? You’d think statics would be
initialised first, the way they are with any other classes. The
JLS (Java Language Specification)
justifies it this way:
The direct superclass of an enum type named E is Enum<E>. In addition to the members it inherits from Enum<E<, for each declared enum constant with the name n the enum type has an implicitly declared public static final field named n of type E. These fields are considered to be declared in the same order as the corresponding enum constants, before any static fields explicitly declared in the enum type. Each such field is initialized to the enum constant that corresponds to it. Each such field is also considered to be annotated by the same annotations as the corresponding enum constant. The enum constant is said to be created when the corresponding field is initialized. The direct superclass of an enum type named E is Enum<E<. In addition to the members it inherits from Enum<E<, for each declared enum constant with the name n the enum type has an implicitly declared public static final field named n of type E. These fields are considered to be declared in the same order as the corresponding enum constants, before any static fields explicitly declared in the enum type. Each such field is initialized to the enum constant that corresponds to it. Each such field is also considered to be annotated by the same annotations as the corresponding enum constant. The enum constant is said to be created when the corresponding field is initialized.In other words, the gotchas is a side effect of the kludgy way enums are implemented. | |
illegal start | illegal start of expression |
| |
incompatible type | Incompatible type for =. Explicit cast needed to convert int to byte. |
missing a cast such as (byte) | |
instance not accessible | Error: An instance of XXX.this is not accessible here because it would have to cross a static region in the intervening type XXX. |
Something is wrong with the parameters to an inner class. | |
invalid declaration | Invalid declaration |
Most likely the name you are trying to declare is invalid. It must not contain dots. It must not start with a digit. | |
invalid label | invalid label |
You used a semicolon instead of a colon after a label. | |
invalid flag | javac: invalid flag: MyClass |
writing javac.exe MyClass or javac.exe MyClass.class instead of javac.exe MyClass.java. | |
invalid method | Invalid method declaration; return type required. |
forgetting void return type on a method declaration. Possibly your constructor and its class name do not match exactly, including case. | |
invalid type | Invalid type expression. |
You forgot the semicolon. | |
javac is not a … command | javac is not an internal or external command operable statement or batch file |
J:\Program Files\java\jdk1.8.0_131\ \bin\javac.exe must be on the path. See JDK for details on polishing and testing your JDK installation. | |
main must be static void | main must be static and void |
An application’s main class must have a method public static void main (String[] args). | |
method cannot hide | The static method XXX declared in class AAA cannot hide the instance method of the same signature declared in class BBB (Better Business Bureau). It is illegal to hide an instance method. |
You can’t use the same name for a static and instance method in a subclass. Either you have to give them different names, or make them both static or make them both instance, or change the signature (parameter types) to make them different. | |
method clone not visible | The method clone() from the type Object is not visible |
If the class containing clone is one of yours, you must implement a public clone method, that will probably use the protected version in its implementation. If the class is built-in, unfortunately, it does not have a public clone method, just a protected clone, which you may not use, unless you write a class extending the built-in class. See clone for details. | |
method matches constructor name | The name of this method XXX matches the name of the containing class. However, the method is not a constructor since its declarator is qualified with a type. |
You can’t put void on a constructor, or put any other return type for that matter. | |
method not found | Method MyClass() not found in MyClass |
| |
misplaced construct | misplaced construct |
| |
misplaced package | Error: com/sun/java/swing/xxx is either a misplaced package name or a non-existent entity. |
Sun renamed com.sun.java.swing to javax.swing but your code is still using the old name. Use a global search and replace on all your *.java files. | |
missing method body | missing method body, or declare abstract |
You inserted a semicolon just before the first { of a method. | |
missing return statement | missing return statement |
No matter how control flows through your method, it must end with a return statement, unless the method has a void return. The most common failing is when you catch an exception. The return in the try body conceptually might never be executed because of an exception potentially being triggered. You need a return in the catch block or after the catch block too. Javac is not as clever as you. You may be sure the exception will never dodge the return in the try block, but javac can’t be so sure. | |
modifier synchronized not allowed | modifier synchronized not allowed here |
synchronized applies to methods and blocks of code. transient applies to variables. | |
name of constructor mismatch | The name of the constructor main does not match name of class MyClass |
You forgot your return type, e.g. void, on a method. | |
no field | No field named length was found in type java/lang/String |
You said s.length rather than s.length() to get the length of a String. The a.length form without the () is only used for arrays. Whereas Lists (e.g. ArrayList) use java.util.List.length(). Collections use Collection.size() just to keep you on your toes. You will even see getLength() every once in a while. The designers of Java must hate newbies to put such stumbling blocks in front of them. It is either laziness of a subtle form of one upmanship. | |
no method found | No method xxx found in class yyy. |
You have the wrong number of parameters or the wrong parameter types for the method. It can also mean you defined a method with the wrong visibility modifier, e.g. none, private or protected when you meant public. Perhaps you called it as if it were static and defined it as instance, or vice versa. Perhaps you were calling a constructor without new. | |
no method matching | No method matching myMethod() found in MyClass |
You have the wrong number of parameters or the wrong parameter types for the method. It can also mean you defined a method with the wrong visibility modifier, e.g. none, private or protected when you meant public. Perhaps you called it as if it were static and defined it as instance, or vice versa. Perhaps you were calling a constructor without new. | |
cap missing | no warning. caps missing. |
| |
impotent setters | no warning. impotent setters. |
| |
missing public | no warning. missing public. |
In debug mode, if you forget to make your main method public, you will not be warned. You won’t discover the problem until later. main must be public static void. | |
case fallthru | no warning. Case fall through is the default. |
missing break. In Java version 1.4 or later you can use the javac.exe -Xswitchcheck to get this error detected. | |
missing initialisation | no warning. Missing initialisation. |
| |
missing variable initialiser | missing variable initialiser |
Don’t put () around the dot-separated parts of a name. | |
constructor treated as method | no warning. Constructor treated as a method. |
specifying a void return type on a constructor. Method with the same name as the class. | |
suspicious shadowing | no warning. reusing instance variable as local. |
You accidentally declared a local variable with the same name as an instance or class variable when you intended to use the instance or local variable. This is my most common error that the compiler does not detect. The Jikes compiler will warn you of this. | |
calling overridden methods in constructor | no warning. calling overridden methods in constructors |
Be very careful calling any methods inside your constructors. If subclasses override them, you will be invoking the subclass’s version, which may be attempting to use fields that have not been initialised yet. You won’t get a warning message! The problem usually shows up as puzzling NullPointerExceptions. The way out is to move code out of the constructor, often to the addNotify method. However, addNotify can get in analogous problem to the constructor since it too is overridden and it may use overridden methods. | |
non-final variable | local variable xxx is accessed from within inner class; needs to be declared final or cannot refer to a non-final variable xxx inside an inner class defined in a different method. |
Inside anonymous classes, you can’t use local variables of the enclosing method unless they are final. I don’t mean instance or static variables. I don’t mean passing locals as parameters to the anonymous constructor. I mean directly accessing local method stack variables directly from anonymous inner class methods. When you do that, they variables have to be final. more details. | |
non-static can’t be referenced | non-static method xxx cannot be referenced from a static context |
| |
not abstract | SomeClass is not abstract and does not override abstract method someMethod. |
You defined a class that extended an abstract class, but you forgot to provide a concrete implementation for one of the abstract methods. | |
Check out all the abstract methods in the base abstract class and make sure you have provided implementations for all of them of them. | |
not a statement | Not a statement |
| |
not accessible | xxx.this is not accessible here because it would have to cross a static region in the intervening type. |
Move your named inner class definition outside a static method. Keep in mind, instances of inner classes must be associated with an instance of the main class. As a corollary of this, you can’t create anonymous inner classes except inside instance methods. | |
not found in import | not found in import. |
The package you mentioned is not available on the classpath. Make sure you spell it with proper case. Make sure you understand the limitations of import wildcards. See import, classpath. | |
not initialised | Local variable x may not have been initialized. There is some execution path from the declaration of x to where you used its value, that avoids setting its value. It often involves an exception. |
missing initialisation for a temporary variable. If you initialise it in a try block, you need also to initialise it in the catch or before the try in case you get an exception. | |
operator + | operator + cannot be applied java.lang.String |
Irritatingly, Java does not allow unary + in front of a String, only between Strings so you can’t write | |
operator || | operator || cannot be applied to int,int |
you wrote if ( x1 = x2 || y1 = y2 ) instead of if ( x1 == x2 || y1 == y2 ) | |
package does not exist | Package Java.Applet does not exist. |
| |
Permission denied | error while writing XXX: XXX.class (Permission denied) |
This will happen in Linux/Unix systems, particularly if you use the Javac.exe -d targetdir option. You are trying to write your generated class files to a directory where you don’t have permission, or the *.class files that you are overwriting may have been generated with a different owner. | |
possible loss of precision | possible loss of precision |
You did something like i = d; where i is an int and d is a double. Narrowing will throw away high order bits or the fraction. You need an explicit cast to acknowledge this loss, e.g. i = (int)d; | |
public class should be in file | public class Xxx should be in a file named Xxx.java. |
Javadoc.exe is particularly picky about case. Make sure the name of the class exactly matches the name of the file and that the name of the package exactly matches the name of the directory tree, e.g. com.mindprod.mypackage.MyClass should be in a file called com\mindprod\mypackage\MyClass.java or com/mindprod/mypackage/MyClass.java, exactly including case of the directory names. | |
reached end of file | reached end of file while parsing |
This is usually a brace balancing problem. You are missing a closing brace, so the parser got to the end while it figured it was still inside the class. The problems can also be caused by unbalanced " and unclosed comments. IDEs (Integrated Development Environments) often have tools to help you balance braces. Code tidiers make unbalanced braces more obvious. For tough case try the BraceBalancer applet/utility. | |
method already defined | valueOf(java.lang.String) is already defined |
There are two causes, one is you simply defined the same method with identical signatures, or signatures differing only in return type in the same class. The other you tried to override the valueOf method in an enum class. There is already a generated hidden implementation in your class, so you can’t override it. Use some other name. The same applies to the automatically constructed methods, compareTo, ordinal and equals. | |
Recompile with -Xlint:unchecked | XXX uses unchecked or unsafe operations. Recompile with -Xlint:unchecked for details |
You used a Collection without generifying it. If it is not obvious what the problem is, recompile with javac.exe -Xlint:unchecked *.java | |
reference ambiguous | reference to xxx is ambiguous, both method xxx(java.lang.String) method xxx(java.lang.Object) match xxx(null). You have two methods with similar signatures. When you call a method with null, there is no type information to help the compiler decide which version to use. Use a typed constant whose value is null. |
repeated modifier | repeated modifier |
You specified a modifying keyword more than once e.g. final or public. | |
return in constructor | 'return' with value from constructor: MyClass(..). |
specifying a return this in a constructor | |
return outside method | return outside method |
you have a return dangling between classes. Perhaps you left the ; before the method {body} in when you converted from abstract method to a real one. | |
return required | Return required at end of MyClass Myclass(..). |
specifying a MyClass return type on a constructor | |
serialVersionUID required | serializable class XXX has no definition of serialVersionUID |
Assign your class a serialVersionUID
/** * Defining a layout version for a class. * Watch the spelling and keywords! */ public static final long serialVersionUID = 3L; | |
should be declared in file | Could not find the main class. Program will exit. |
There is a problem with the Main-Class entry of manifest in the jar file. Possibly you got the package name wrong or the case of the name off. The Main-Class must exist in an element of the jar filed under the package name as the folder. Possible the Class you specified is missing a public static void main(Strings[] args) method. Check the gotchas in setting up the manifest. | |
statement expected | Statement expected. |
missing } in a method | |
static not valid on constructor | static is not a valid constructor modifier |
You forgot your return type e.g. void, on a method. | |
static field should be accessed in a static way. | The static field Calendar.HOUR_OF_DAY should be accessed in a static way. |
You specified c.HOUR_OF_DAY where c is a Calendar instance reference. You should get at the static constant with Calendar. HOUR_OF_DAY. | |
Tag @see : reference not found | Must have a class or method signature |
You should have something of the form @see java.lang.String or java.lang.String#indexOf(char). Most commonly you have left off the parameters on a method. The target must be in the standard System Javadoc or in the Javadoc bundle. You can’t point to a class whose Javadoc is not in the bundle. | |
superclass not found | Superclass YYY of class XXX not found. |
Did you remember to import the YYY class? | |
type can’t be private | The type MyClass can’t be private. Package members are always accessible within the current package. |
Top level classes can’t be private, only classes nested inside others. | |
type cannot be widened | the type of this expression, 'double', cannot be promoted to 'int' by widening conversion. |
Java cannot automatically convert a double to an int. There are many options. See Converter Amanuensis for the code you need. | |
type expected | Type expected. identifier expected. |
| |
type safety | Eclipse error: Type safety: Unchecked invocation sort(List<X>) of the generic method sort(List<X>) of type Collections X |
You forgot to generify your X implements Comparable<X> and similar differences for generics documented under Comparable. | |
type safety: erased type | Type safety: The cast from Object to ArrayList<String> is actually checking against the erased type ArrayList. |
The compiler is warning you that the cast you are doing is only ensuring the Object is an ArrayList. It can’t tell if it truly is an ArrayList< String>. If it isn’t, on your head be it. If it is not really an ArrayList< String> expect a ClassCastException as soon as you do a get, even though there are no explicit casts near the get in your code. The problem in essence is that serialized objects contain no record of their generic type. Many think that design decision was a big mistake. | |
unable to resolve class | anable to resolve class: xxxx |
This happens when genjar is building a jar. It can be caused by a missing class file that is needed for the jar, but more frequently is just happens for no apparent reason. You can try rebooting is case the problem is some other application has the needed class file locked. Earlier versions of genjar did not even tell you which class file it was having trouble with. | |
unchecked cast | warning: [unchecked] unchecked cast |
This is a subtle problem. The root cause of it is type erasure. All information the compiler has about generics is erased from the run time. You did a run-time cast that would require the run time to have knowledge of the generic information. In Java version 1.5 or later, you can use a @SuppressWarnings to pat the compiler on the head and say There there. I know what I am doing. Not to worry. | |
unchecked conversion | Warning: [unchecked] unchecked conversion |
You used a Collection without generifying it. If it is not obvious what the problem is, recompile with javac.exe -Xlint:unchecked *.java | |
unclosed character literal | unclosed character literal |
Single char literals are enclosed in ’s. Strings, including empty and 1-character Strings are enclosed in "s. You may have used an invalid representation for a char literal. You may have tried to put a string of more than one character between the 's. char literals that need quoting include: '\"', '\'', '\n' and '\\'. | |
unclosed string literal | unclosed string literal |
String literals are enclosed in " characters. Check the lead and trail character to make sure it is indeed a " not something similar looking. Check for awkward characters (e.g. " ' \ ) embedded in the string and make sure they are preceded by a \. For a string made up of pieces, make sure there is a + between each pair. | |
undefined reference to main | undefined reference to main with gcj. |
If you are using the gcj Java compiler, you left off the --main command line option or you screwed it up in some way. It needs the fully qualified name of your main class, which will necessarily have a public static void main method. | |
undefined variable | Undefined variable x; or Variable x in SomeOtherClass not accessible from MyClass Incompatible type for =. |
| |
unexpected symbols | Unexpected symbols ignored. |
You just coded a snippet. All code has to live inside a method and all methods have to live inside a class. The only exception are static and instance initialisers, which must be contained in {} inside a class. | |
unqualified enumeration required | unqualified enumeration constant name required |
This is the Java version 1.5 or later enum type checking catching you. Your enum constant on a case is not of the same type as the variable in the switch. | |
unreachable statement | statement unreachable |
You have written some code that could never be executed, e.g. you put some code immediately after a throw or return statement. | |
unreported exception | Unreported exception java.text.ParseException; must be caught or declared to be thrown. |
The code potentially throws an exception. You must either wrap
it in a try {…} catch (ParseException e) {…} or put a throws declaration on the method to let the caller deal with it. | |
unsorted switch | Unsorted lookup switch |
Java won’t let you have two different symbolic constants as case labels if they have the same numeric value, even if they label the same block of code. | |
void type | 'void' type not allowed here |
You are using a method that does not return a value in a place where a value is required such as the right side of an equal sign or a parameter to another method. | |
weaker access | Attempting to assign weaker access privileges; was public. |
The original method you are overriding was public. Your overriding method must be public too. This often happens when you implement a method in an interface. All methods in an interface are implicitly public abstract. However, when you implement them, you must explicitly specify the public. | |
{ expected | Syntax: { expected after this token |
| |
} expected | } expected. Type expected. Identifier expected. |
|
This page is posted |
http://mindprod.com/jgloss/compileerrormessages.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\compileerrormessages.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[18.119.142.210] |
| |
Feedback |
You are visitor number | |