Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The type java.lang.CharSequence cannot be resolved in package declaration

Tags:

java

eclipse

I get 2 classes in package P. Interface class A and its implementation class B. In the file with class B I get the following error: The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files.

I'm using Eclipse Helios and

$ java -version java version "1.8.0_05" Java(TM) SE Runtime Environment (build 1.8.0_05-b13) Java HotSpot(TM) Server VM (build 25.5-b02, mixed mode) 

Standard solution of removing and adding JRE doesn't work. How can I fix it?

EDIT: Code:
Class A:

package com.jax;  import javax.jws.WebMethod; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.jws.soap.SOAPBinding.Style;   @WebService @SOAPBinding(style = Style.RPC) public interface WebServiceInter {  @WebMethod String sayHello();  } 

Class B:

package com.jax; // **Error is here**  import javax.jws.WebService;  @WebService(endpointInterface = "com.jax.WebServiceInter") public class WebServiceImpl implements WebServiceInter{     @Override     public String sayHello(){         return "Hello!";     } } 

Project structure: ProjectName -> Java Resources -> com.jax -> Class A, Class B

like image 796
user3712116 Avatar asked Jun 19 '14 08:06

user3712116


People also ask

Is there a way to resolve charsequence in Jaspersoft?

The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files | Jaspersoft Community Home » Answers » The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files

Why can't I resolve charsequence type?

"The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files". With the helps of internet, I guess that the reason of this trouble may be version mismatch between JDK and Java EE SDK, or something else mismatch.

How to get rid of default methods in charsequence interface?

First solution is to rollback to JDK 7, then you will use old CharSequence interface without default methods. Second solution is to set source level of your project to 1.8, then your compiler will not complain about default methods in interfaces.


1 Answers

Java 8 supports default methods in interfaces. And in JDK 8 a lot of old interfaces now have new default methods. For example, now in CharSequence we have chars and codePoints methods.
If source level of your project is lower than 1.8, then compiler doesn't allow you to use default methods in interfaces. So it cannot compile classes that directly on indirectly depend on this interfaces.
If I get your problem right, then you have two solutions. First solution is to rollback to JDK 7, then you will use old CharSequence interface without default methods. Second solution is to set source level of your project to 1.8, then your compiler will not complain about default methods in interfaces.

like image 131
mkrakhin Avatar answered Oct 25 '22 20:10

mkrakhin