I'm getting a error trying to compile a simple code in Eclipse. I'm using jre8.
For example, when I try to compile this code:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class MyProject {
public static void main (String args[])
{
List<String> myList = new ArrayList<String>();
myList.add("test");
myList.add("test2");
Collections.sort(myList);
}
}
I get a error in the Collections.sort(myList);
line.
The error is:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
at project.Principal.main(Principal.java:14)
I have already opened eclipse Build Path, removed JRE System Library [jre8] and added it again. But didn't work! What can I do? Thanks!
PS.: In the Collections.sort(myList);
line eclipse shows this error:
The type java.lang.CharSequence cannot be resolved. It is inderectly referenced from required .class files.