Java Syntax Errors
NOTE: New user registration will be down until the end of July.
This wiki is for sharing information about syntax errors in Java. It is probably going to start somewhat slowly, but I'm okay with that. This page is the starting point for the content. See the Community portal for information about how you can contribute, about the project, and about our community.
Note that, until other people start using this wiki, the syntax errors will reflect Eclipse usage. That's because I (Ducky Sherwood) use Eclipse. I'd be delighted for others to help me make it more inclusive.
I don't mind at all if the list below gets extremely long. I expect that people will find this site by plugging their error message into a search engine -- which should take them to the error discussion before bringing them to this page. The main purpose of this page is thus to tell search engines where pages are; letting humans read it is secondary in importance.
- The hierarchy of the type Foo is inconsistent
- Bundle 'a.b.c' cannot be resolved
- The import a.b.c cannot be resolved
- Foo cannot be resolved, including
- Foo cannot be resolved to a type
- The type a.b.c.Foo cannot be resolved. It is indirectly referenced from required class files.
- The constructor Foo(Bar) is undefined
- Syntax error on token "Foo", VariableDeclaratorId expected after this token
- Syntax error on token ".", invalid VariableDeclarator
- The public type Foo must be defined in its own file. (Eclipse?)
- Type mismatch: cannot convert from a Foo to a Bar.
- The constructor Foo() is undefined
- void methods cannot return a value
- Cannot instantiate the type Foo
- NULL cannot be resolved
- The method Foo() is undefined for the type Bar
- Constructor call must be the first statement in a constructor
- Cannot refer to an instance method while explicitly invoking a constructor
- The constructor String(int) is undefined
- The operator < is undefined for the argument type(s) java.lang.String
- Project 'foo' is missing required Java project: 'a.b.c'
- Unhandled exception type FooException
- No exception of type void can be thrown; an exception type must be a subclass of Throwable
- Array constants can only be used in initializers
- Implicit super constructor Foo() is undefined for default constructor. Must define an explicit constructor
- No enclosing instance of type Foo is accessible. Must qualify the allocation with an enclosing instance of type Foo (e.g. x.new A() where x is an instance of Foo).
- The method compareTo(String) in the type String is not applicable for the arguments (Object)
- Type mismatch: cannot convert from Object to Foo
- The method add(int, Object) in the type ArrayList is not applicable for the arguments (int)
- Syntax error, insert ")" to complete ClassInstanceCreationExpression
- Duplicate modifier for the method bar in type Foo
- Syntax error on token "catch", finally expected
- Syntax error on token "return", invalid EnumHeader
- Syntax error, insert "enum Identifier" to complete EnumHeader
- Syntax error, insert ";" to complete ReturnStatement
- Syntax error on tokens, delete these token
- Syntax error on token "}", delete this token
- Syntax error on token ")", ; expected
- Syntax error, insert ")" to complete (something)
- Syntax error on token "&&", invalid OnlySynchronized
- Inconsistent classfile encountered: The undefined type parameter K is referenced from within Foo
- The method foo(Bar<Baz>) in the type Foo<Baz> is not applicable for the arguments (Wacka) shoot, forgot to log this one
(What do all these things mean?)
- Meaning of VariableInitializer
- Meaning of Expression
- Meaning of MethodInvocation @@@ check that this is the right term
- Meaning of LocalVariableDeclarationStatement
- Meaning of ClassInstanceCreationExpression
Other syntax issues
These are things that aren't exactly syntax errors but aren't exactly not...
- No tests found with test runner JUnit4 (Eclipse)
- junit.framework.AssertionFailedError: No tests found in a.b.c.FooTest