0

I have a project in my eclipse. When I upgraded Java from 1.8.0_77 to 1.8.0_131, eclipse started showing method is undefined error. I have configured proper JRE.This might be duplicate of this but did not find solution over there.

enter image description here

Some of missing methods are:

  • String#split
  • String#contains
  • String#replaceAll
  • Long#valueOf
  • etc.
Michael Peyper
  • 6,814
  • 2
  • 27
  • 44
Vikas
  • 6,868
  • 4
  • 27
  • 41
  • 2
    What the method is actually undefined? Could you show us your code, please? – Andrii Abramov Jun 13 '17 at 06:14
  • and, are you sure that it only require JRE but not JDK? – Adrian Shum Jun 13 '17 at 06:15
  • 1
    @AndriiAbramov there are many methods for which im getting this error. Some of these are split,contains,replaceAll from String class, valueOf from Long and many more. simDataObj.setAttribute("email_id", Long.valueOf(emailId)); – Vikas Jun 13 '17 at 06:26
  • @Andrian Shum Yes I corrected it to JDK but still same issue – Vikas Jun 13 '17 at 06:30
  • Go to Project name -> Properties -> Java build Path -> Libraries tab. Next click `add library` and add jre – Jay Smith Jun 13 '17 at 06:34
  • The methods you quoted that were missing seems all comes from JDK >= 1.5. Have you set to use a low compiler compliance level? Preference -> Java -> Compiler, check "Compiler compliance level" – Adrian Shum Jun 13 '17 at 06:41
  • @AdrianShum I also thought of this but no luck. Compiler compliance level is set to 1.8 – Vikas Jun 13 '17 at 06:59
  • Have you checked project specific settings? Remember project specific settings overrides the defaults. – Adrian Shum Jun 13 '17 at 07:19

2 Answers2

0

Try to check your Project Build Path. To do that

  1. Right click your project -> Build Path -> Configure Build Path.
  2. In the Libraries tab, try to check if your JRE library exists.

Since you remove your previous JRE in the Installed JREs, my hunch is your project is still set or looking for the previous version of JRE. If its not existing, add it by clicking the Add Library in the Libraries tab. Select JRE System Library and look for your latest JRE.

Hope this helps.

anonymouse
  • 109
  • 2
  • 9
0

Finally fixed the issue. Instead of using Installed JRE or Workspace default JRE, I used Execution environment value(JavaSE-1.8) as JRE system library shown in screenshot and this solved my issue. Thanks to all for your help.

enter image description here

Vikas
  • 6,868
  • 4
  • 27
  • 41