3

I recently updated my JDK version to 8. I have a piece of code which looks like :

     StringBuilder abc = new StringBuilder();
     abc.append("123");

when I run this, It is throwing error:

The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files

I have updated all the dependencies of JDK, but noting helped.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user3593123
  • 41
  • 1
  • 3

2 Answers2

3

I just suffered it yesterday. It's because your server (tomcat I guess?) doesn't support Java 8 (for the version you've).

It's known that tomcat6 and some of the first version of tomcat7 doesn't support Java 8. You would have to update your server or compile it back with Java 7.

From the reference I leave below, Brett Bryan said:

I can confirm that apache-tomcat-7.0.35 does NOT have support for JDK8, I can also confirm that apache-tomcat-7.0.50 DOES have support for JDK8.

Reference: Unable to compile class for JSP: The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files

Community
  • 1
  • 1
Btc Sources
  • 1,912
  • 2
  • 30
  • 58
  • same problem on my side, i had jdk8 in my eclipse set, and running my app on was liberty, after switch back to jkd7 everything works fine – To Kra Jun 20 '16 at 13:07
0

I have face the similar issue in java upgrade to v1.8. This problem is due to use of lower version of servlet api (< 3.0).

Solution: 1: Either degrade Java 8 to Java v7 or 2: Upgrade the servlet api version to 3.0 or higher.

Pramod Yadav
  • 81
  • 1
  • 4
  • I just upgraded my Servlet version to 3.1 but didn't work. Is it required to upgrade the jetty too. My older jetty has version 6.5. Do I need to upgrade to Jetty 9? – vibhas Dec 01 '17 at 08:47
  • Yes You have to bring Application server/container compatible with Latest Specification. – Pramod Yadav Dec 01 '17 at 10:56