Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
compile time error messages This table contains errors detected at compile time. If you dont find your error listed here, send me an email at containing the complete source code so I too can compile it and I will figure out what it means, and add it to this list.
classname not enclosing class Comparable cannot be inherited constructor calls overridden method constructor used as method
Are you a developer? Try out the HTML to PDF API
= expected [ expected already defined ambiguous class array not initialised attempt to reference attempt to rename bad class file blank final boolean dereferenced bound mismatch cannot find symbol cannot override, attempting weaker access cannot override, does not throw cannot override, incompatible return type
reached end of file recompile with -Xlint:unchecked redefined method reference ambiguous repeated modifier return in constructor return outside method return required serialVersionUID required should be declared in file statement expected static field should be accessed in a static way
static not valid on constructor
generic array creation identifier expected illegal character illegal escape illegal forward reference illegal reference to static illegal start impotent setters incompatible type
pdfcrowd.com
cannot resolve symbol constructor Thread cannot resolve symbol this cannot use operator new cant access class cant be applied cant be dereferenced cant be instantiated; cant convert from Object to X cant delete jar file cant determine application home cant instantiate abstract class cant make static reference capitalisation errors case fallthru char cannot be dereferenced clashes with package
class expected
invalid flag invalid label invalid method invalid type javac is not a command main must be static void method cannot hide method clone not visible method matches constructor name method not found misplaced construct misplaced package missing init missing method body missing public missing return statement missing variable initialiser name of constructor mismatch no field
superclass not found suspicious shadowing Tag @see: not found type cant be private type cant be widened type expected type safety type safety: type erased unable to resolve class unchecked cast unchecked conversion unclosed character literal unclosed String literal undefined reference to main undefined variable unexpected symbols unqualified enumeration required unreachable statement unsorted switch
pdfcrowd.com
class names only accepted for annotation class not found class not found in import class not found in type declaration class or interface declaration expected class should be declared in file
Compiler Error Messages
reached end of file while parsing"
no method found no method matching non-final variable non-static cant be referenced not a statement not abstract
// oops missing [] in attempt to define an array literal new String { "x", "y" };
instead
. expected
You must import either a packagename.* or packagename. Classname. You cant just import packagename or import Classname. You dont import classes in the same package as the current class. In other words, the thing you import will always contain at least one .. You dont 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
pdfcrowd.com
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 dont import classes without packages.
.class expected
you wrote int i where you meant just plain i.
'.class expected
; expected
Usually this is just a missing semicolon, sometimes it can be caused by unbalanced () on the previous line.
semicolon expected.
sometimes it can be cause by junk on the previous line. This junk might be far to the right off the screen. Sometimes it is caused by spelling the keyword if incorrectly nearby. Sometimes it is a missing + concatenation operator. C programmers often make this one on multi-line Strings since the concatenation operator is implied in C. ';' expected. 'else' without if. statement expected. invalid expression.
; missing
missing semicolon. See ; expected .
= expected
Look for a stray } just before where it is complaining.
= expected.
[ expected
Likely you wrote [i,j] instead of [i][j].
Missing [
already defined
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;
open in browser PRO version
Are you a developer? Try out the HTML to PDF API
pdfcrowd.com
// 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.
import
array not initialised
You forgot to initialise an array with new int[5]. Array a may not have been initialized.
attempt to reference
missing dummy pair of parentheses after the 0-argument method name.
attempt to rename
Your jar is in use by some running Applet or application. Shut it down to build and sign the jar.
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.
pdfcrowd.com
Boolean 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>>
Cant access com.mindprod.mypackage.MyClass. Only classes and interfaces in other packages can be accessed.
You forgot to make the class public. In JBuilder, check the properties for your project. Your root directories should be plain C:\ not C:\com\mindprod\thepackage
cant be applied
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 aint what you dont know that gets you into trouble. Its what you know for sure that just aint so. ~ Mark Twain (born: 1835-11-30 died: 1910-04-21 at age: 74)
cant 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 cant have any instance methods. They can be parameters to either static or instance methods though. load: com.mindprod.mypackage.MyApplet.class cant be instantiated.
cant 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
pdfcrowd.com
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 navely expect. You tried to use a general Object reference in a context that requires something more specific. Sometimes all you need is a cast.
Uninstall all Java JDKs (Java Development Kits) and JREs (Java Runtime Environments) with the Control Panel. Use Microsofts RegClean. Tidy up the registry with regedit. Reinstall just the latest JDK (Java Development Kit).
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 classs 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: Wrong syntax for calling: constructor: new X(), instance: x. someMethod(), static:SomeClass.someMethod(). The method you want is protected or private. You left out a parm. You added an extra parm. You have the parms in the wrong order. You have the type of a parm wrong, e.g. it wants a File, but you gave it a String. Symbols are case sensitive. You have a mismatch. Confused package. Javac.exe is looking in the wrong package or class, e.g. java.util.List vs java.awt.List. Use fully qualified references to rule that out. The referenced class did not compile because it has a syntax error. The needed class/jar files are not on the classpath. Cannot find symbol method sort(java.util.ArrayList<Xxx>) could mean you have not implemented Comparator on the class you are trying to sort. There is some other syntax error, than the compiler interprets its strange way as an undefined symbol.
pdfcrowd.com
Using the -verbose option on javac.exe will give you hints to help resolve this error. Cannot Resolve Symbol
cannot override
You can override a default or protected method with a public one, but not the reverse.
toString() in xxx cannot override toString() in java.lang.Object; attempting to assign weaker access privileges; was public.
cannot override
Overridden methods cannot add any throws clauses not in the base method they are overriding.
toString() in xxx cannot override toString() in java.lang.Object; overridden method does not throw java.io.IOException
cannot override
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.
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 , e.g. you are trying to use a variable defined inside a loop outside
Possibly you are trying to use a constructor without new as if it were an ordinary method. If the error message is pointing to code that uses the standard classes, chances are you either misspelled it, or forgot to import the class, or misspelled the import. If it is pointing to one of your methods or variables chances are you misspelled it either in the definition or reference. Java is picky. You must get upper-lower case precisely correct too.
pdfcrowd.com
If the code is pointing to one of your classes that is clearly there, perhaps you forgot to put C:\ on the classpath the mother of all packages where com is in com.mindprod.thispackage lives. If you are not using packages, perhaps you forgot to put. on your classpath. A symptom of this is you can compile successfully if you rebuild everything, but not if you just recompile the changed modules. You are using a method of the object when the reference is to an interface that does not contain that method. Either cast to specific object, or change the reference to a specific object reference, e. g.
// Using subclass methods. // In this case, MultiFilter.addNever() is implemented // in MultiFilter but not in the base FileNameFilter. // oops. f. has no addNever method. FileNameFilter f = new MultiFilter(); f.addNever( never ); // should read FileNameFilter f = new MultiFilter(); ((MultiFilter)f).addNever( never ); // or more efficiently MultiFilter f = new MultiFilter(); f.addNever( never );
addNever is a method of MultiFilter, but not of FileNameFilter. Watch for subtle spelling differences between declaration and reference, e.g. Hashtable and HashTable. Copy/paste the definition on top
of the reference to be sure they are absolutely identical. Your eyes can fool you. In an implements clause, you may have used a period where you should have used a comma. If is complaining about the superclass of your constructor, the problem is you must either explicitly call super(), or there must be a superclass constructor with a matching signature.
pdfcrowd.com
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.
You cant 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.
You have tried to use a String or other Object method on a char or char[] which have no instance methods.
Rename your class or rename your package so they dont have the same name. Usually this is not a problem since package names normally have dots in them.
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.
Getting the capitalisation wrong in the filename on the javac command line or in the filename itself. 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:
pdfcrowd.com
javac.exe MyClass.java
This is one of the most maliciously misleading of all error messages.
Some other syntax error ahead of the class declaration is preventing the compiler from seeing the class declaration. The class is not in the proper file in the proper directory. The class is not public. The class does not have the correct case, either in the class name or the file name. The corresponding class or java file is not on the CLASSPATH (considering the package name.) 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. importjava.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.
You forgot to import java.awt.event.* or to fully qualify java.awt.event.WindowAdapter. Im 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.
Put your package statement before all the imports. The imports come before your class declarations. Make your class public, not protected.
pdfcrowd.com
You may have too many } so that you have finished off your class before you intended too. Using a source code beautifier block and {} will help make these sorts of errors obvious.
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.
The name of the *.java file must precisely match the name of the public class it defines. The name is case sensitive.
You are attempting to instantiate a non-static named inner class without an instantiated the outer class. Solution: declare the named inner class as static or instantiate your inner class like this as described under nested classes . You used an expression like JApplet.this in an inner class. You must specify the precise name of the enclosing class, e.g. MyApplet. this not one of its superclasses. If you wanted a superclass reference you would have to use (JApplet) MyApplet. this. Comparable cannot be inherited with different arguments
}
The best way I know of to bypass the problem is to write both classes without the implements Comparable. Then write two Comparators instead.
pdfcrowd.com
Duplicate class
You misspelled the package name on the package statement. It must match the name of the directory containing the Java source. duplicate method declaration
You have two methods with the same name and the same signature i.e. number and types of parameters. You cant have two methods that differ only in return type.
enum as 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 <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 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
The wording is ambiguous. You might think it means the parameter might, under some circumstances, escape being assigned. That is not what it means.
You might have written new ArrayList <String>[ 100] instead of new ArrayList< String>( 100); To be charitable, Javas generics are Mickey Mouse. One of the side effects of the el-cheapo implementation is that you cant have arrays of generic collections, e. g. the following is illegal
pdfcrowd.com
// You cannot use "new" to allocate an array of T where T is a generic type, e.g. <T>. // Recall that even if it did, it would still allocate an array of Objects at run time. T[] things = new T[10]; // Illegal attempt to create an array of generic collections. ArrayList<String>[] stuff = new ArrayList<String>[ 10 ];
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
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
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.
literals
illegal forward reference
Probable forward enum reference
You may not reference an enum constant that has not yet been defined. I.e. you can reference other enum constants in an enum constructor call.
enum constructors cannot access the enum static fields. However, they can invoke the enums static methods that access the static fields, but they wont 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
pdfcrowd.com
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? Youd 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. ~ Java Language Spec In other words, the gotchas is a side effect of the kludgy way enums are implemented.
illegal start
The error message will point to perfectly good code. Look just ahead of it for a missing } static int x = 0; Static variables have to be defined outside all methods inside a class. you wrote x + = 2; instead of x += 2; You also may have used an ) when you meant a }. you wrote case: STRAWBERRY instead of case STRAWBERRY : You nested a method inside another method. or ;
incompatible type
missing a cast such as (byte)
Error: An instance of XXX.this is not accessible here because it would have to cross a static region in the intervening type XXX.
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.
pdfcrowd.com
invalid label
You used a semicolon instead of a colon after a label.
invalid label
invalid flag
invalid method
forgetting void return type on a method declaration. Possibly your constructor and its class name do not match exactly, including case.
invalid type
You forgot the semicolon.
javac is not an internal or external command operable statement or batch file . See JDK for details on polishing and testing your
An applications main class must have a method public static void main (String[] args).
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 cant 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.
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. 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.
pdfcrowd.com
misplaced construct
misplaced construct
You wrote doSomething( String[] choices ) rather than doSomething( choices ) There is a stray } just before of where it is complaining. Error: com/sun/java/swing/xxx is either a misplaced package name or a non-existent entity.
misplaced package
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.
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 cant be so sure.
The name of the constructor main does not match name of class MyClass
no field
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 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
pdfcrowd.com
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
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
missing caps on a class name declaration. Caps on a variable/method declaration
impotent setters
// // // // //
This method does nothing, just sets this.brush to itself. Note misspelling brash for brush. No warning! Eclipse compiler will warn you though. public voidsetBrush ( int brash ) { this.brush = brush; }
no warning. missing public.
missing public
In debug mode, if you forget to make your main method public, you will not be warned. You wont discover the problem until later. main must be public static void.
case fallthru
missing break. In Java version 1.4 or later you can use the javac.exe -Xswitchcheck to get this error detected.
missing initialisation
pdfcrowd.com
The array is automatically initialised to null. This will likely soon lead to a java.lang.NullPointerException when you try to apply some method to one of the elements of the array. Note Null PointerException, not NullReferenceException. You forgot to initialise an array of strings or objects to some value. You forgot to initialise an int array to some value or populate it with objects.
suspicious shadowing
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.
JPCC
The Jikes compiler will warn you of this.
Be very careful calling any methods inside your constructors. If subclasses override them, you will be invoking the subclasss version, which may be attempting to use fields that have not been initialised yet. You wont 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. 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.
non-final variable
Inside anonymous classes, you cant use local variables of the enclosing method unless they are final. I dont mean instance or static variables. I dont 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 .
pdfcrowd.com
In a static method, you used an instance method without an object, e.g. MyClass.xxx(). You must first create an object with MyClass o = new MyClass();, then use o.xxx(); to invoke the method. You used an instance variable (one without the static attribute) inside a static method. static methods dont have access to any particular object, so cant use any of the instance (per object) fields. You may have used a reference to an inner class inside a static method. Make that inner class an ordinary separate class. Inner classes are always linked to an instance of the main class. You may have tried to instantiate an inner class in some static code. You need to make the inner class static to be able to use it without a mother object. You tried to access an instance variable or method of the outer class from static nested class. You tried to instantiate/reference a non-static inner class from a static method of the outer class. Either make the inner class static, or make it an independent class, or make the invoking method an instance method. This sounds bizarre, but you were using an enum with some enum private methods. Remove the private keyword and magically all will work. Use an IDE like IntelliJ Idea to show you will methods can be private. This is a side effect of the way enums are implemented. enum constants with a body of their own methods are implemented as anonymous inner classes defined in a static init block. They cant access the private methods of the mother class. The error message is misleading. The problem is one of scope, not 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
The compiler was expecting a statement and you gave it something else, e. g. you wrote if (i > 7) 42;. You might have used a variable name beginning with a digit or punctuation or some other improper character. Perhaps you used == instead of = in an assignment statement, turning it into an expression instead of a statement. you wrote x + = 2; instead of x += 2; Perhaps you had a stray semicolon in a statement made of dozen of concatenations. xxx.this is not accessible here because it would have to cross a static region in the intervening type.
not accessible
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 cant create anonymous inner classes except inside instance methods.
pdfcrowd.com
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 . 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.
not initialised
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 +
Irritatingly, Java does not allow unary + in front of a String, only between Strings so you cant write
// oops, lead + not allowed even though it would be nice for alignment and consistency result = + "cow " + "rabbit " + "horse ";
operator ||
you wrote if ( x1 = x2 || y1 = y2 ) instead of if ( x1 == x2 || y1 == y2 ) operator || cannot be applied to int,int
Java is case sensitive. The package is called java.applet, not Java.Applet[sic]. Package names are supposed to be pure lower case. Check that the package is available on the classpath or in some jar in the appropriate ext directory. You can use winzip to examine the jar file directories to find out which classes they contain. To help discover which jar does contain your class use google on the package name + jar. Then get that jar on the classpath or in the ext directory. This error can so come up when you try to allocate an inner class object, e.g.
import java.awt.geom.Ellipse2D;
...
// allocate an inner class Float object of the Ellipse2D class return new Ellipse2D.Float( x, y, w, h );
open in browser PRO version
Are you a developer? Try out the HTML to PDF API
pdfcrowd.com
You should use an import for the outer class. You dont need to import the inner, though you may optionally do so. Dont try to use * notation to import the inner class.. error while writing XXX: XXX.class (Permission denied)
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 dont have permission, or the *.class files that you are overwriting may have been generated with a different owner.
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;
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.
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.
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 cant override it. Use some other name. The same applies to the automatically constructed methods, compareTo, ordinal, and equals.
XXX uses unchecked or unsafe operations. Recompile with -Xlint:unchecked for details it. If it is not obvious what the problem is, recompile with javac.exe -Xlint:unchecked 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.
*.java
pdfcrowd.com
reference ambiguous
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
specifying a return this in a constructor
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
specifying a MyClass return type on a constructor
serialVersionUID required
Assign your class a serialVersionUID
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 }
pdfcrowd.com
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.
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 cant point to a class whose Javadoc is not in the bundle.
The type MyClass cant be private. Package members are always accessible within the current package.
the type of this expression, ' double', cannot be promoted to 'int' by widening conversion. for the code you need.
Java cannot automatically convert a double to an int. There are many options. See Converter Amanuensis
type expected
Type expected. identifier expected. , or literally a missing type, especially in constant declarations like: public static final SOMETHING=3; instead of public
extra }
type safety
You forgot to generify your X implements Comparable<X> and similar differences for generics documented under Comparable
Type safety: The cast from Object to ArrayList<String> is actually checking against the
pdfcrowd.com
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 cant tell if it truly is an ArrayList< String>. If it isnt, 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.
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
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 runtime 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
You used a Collection without generifying
Warning: [unchecked] unchecked conversion it. If it is not obvious what the problem is, recompile with javac.exe -Xlint:unchecked unclosed character literal
*.java
Single char literals are enclosed in 's. Strings. 1-character Strings are enclosed in "s. You may have used ' around a String, or used an invalid representation for a char 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.
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 =.
pdfcrowd.com
unexpected symbols
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.
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
The code potentially throws an exception. You must either wrap it in a
java.text.ParseException; must be
caught or declared to be thrown.
or put a throws declaration on the method to let the caller deal with it. Unsorted lookup switch
Java wont 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
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
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
Look for a missing { slightly before where it is complaining.
Usually it means you put a semicolon where one was not supposed to be ahead of a {, such as at the end of an implements or extends clause.
pdfcrowd.com
Usually it means you put a semicolon where one was not supposed to be ahead of a {, such as at the end of an implements or extends clause. There are many errors of this type the compiler cannot catch because Java slavishly copied C syntax. For example, getting your semicolons wrong in a for loop will generally not generate an error, just give surprising results.
} expected
Missing }
Missing } is on a line containing // before the }. Failure to enclose initialiser code in {} or static {}. Code has to live inside some method, or inside some initialiser. It cant just be left lying out in the middle of the class declarations. forgetting static { } around class init code. Perhaps
// Oops, interfaces extend other interfaces, // only classes can implement them. interface X implements Y { // ... }
instead
// Correct. An interface extends another interface, // it cannot implement it. // A class extends another class or implements an interface. // An interface cannot extend or implement a class. interface X extends Y { // ... }
pdfcrowd.com
available on the web at: optional Replicator mirror of mindprod.com on local hard disk J:
http://mindprod.com/jgloss/compileerrormessages.html J:\mindprod\jgloss\compileerrormessages.html
Please email your feedback for publication , letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : . If you want your message, your name or email kept confidential, not considered for public posting, please explicitly specify that. Unless you state otherwise, I will treat your message as a letter to the editor that I may or may not publish in the feedback section. After that, it will be too late to retract it. If you disagree with something I said, especially when sending an ad-hominem attack, a rant composed mainly of obscenities or a death threat, please quote the offending passage and cite the web page where you found it, tell me why you think it is wrong, and, if possible, provide some supporting evidence. I cant very well fix erroneous or ambiguous text if I cant find it.
Blog Feedback
584,435.
pdfcrowd.com
Poorly secured nuclear material in the former Soviet Union, or secrets from a scientist in Pakistan could help build a bomb that detonates in Paris. The poppies in Afghanistan become the heroin in Berlin. The poverty and violence in Somalia breeds the terror of tomorrow. ~ Barack Obama (born: 1961-08-04 age: 52)
pdfcrowd.com