Generic Compile time Error
The method (methodName) undefined for the type (className)
Specific errors
The method contains(String) is undefined for the type String
The method codePointAt(String) is undefined for the type String
The method codePointBefore(String) is undefined for the type String
The method offsetByCodePoints(String) is undefined for the type String
The method replace(String) is undefined for the type String
The method contentEquals(String) is undefined for the type String
The method format(String) is undefined for the type String
The method getTypeParameters(typeVariable) is undefined for the type typeVariable
The method getGenericReturnType(Type) is undefined for the type Type
The method isBridge(Boolean) is undefined for the type Boolean
The method getDefaultValue(Object) is undefined for the type Object
The method checkedSet(Set) is undefined for the type Set
The method checkedSet(List) is undefined for the type List
The method emptyList(List) is undefined for the type List
The method getResources() is undefined for the type
The method getSystemService(String) is undefined for the type List
Problem
This error message appears in java when the method is not defined in that class. If you getting these errors for methods related to String or Collection Classes most likely the problem is because of JDK compliance level or installed JRE. All these methods compiles with JDK 1.5 or above.
Changing the JDK compliance level
Changing JDK compliance level for workspace
Step 1 - Go to Windows -> Preferences
Step 2 - Click Compiler within left navigation and then Compliance and Classfiles tab.
or you can change the JDK compliance level just for the project.
Step 1 - Right click project and click properties
Step 2 - Click Java Compiler in the left navigation and then click Compliance and Classfiles tab.
Step 3 - Change the compliance level using Compiler compliance level dropdown.
If you are not able to see level 1.5 , this means the problem could be due to outdated JRE used.
Update to new JRE.
Step 1 - Download the JRE with JDK 1.5.
Step 2 - Go to Windows -> Preferences -> Installed JREs
Step 2 - Click Add to Add a new JRE
Step 3 - Browse to the new JRE location and select the JRE folder
Compile again and this should resolve the problem.