18

After I configured Eclipse Oxygen to work with Java 9, when I go to Source => Generate toString() I get this error message:

Cannot create method implementations.
Reason: module:java.base is not on its project's build path

Generating the constructor, getters and setters, hashcode() and equals() works fine, only the toString() doesn't work.

If I type the toString() method manually it works fine. Also if I create a project using the JRE 8, generate toString() work fine. Any ideas how to fix it?

Naman
  • 27,789
  • 26
  • 218
  • 353
BrunoJustino
  • 195
  • 1
  • 7
  • What default way do you use while generating the `toString()`? Does it require `StringBuffer` or `StringBuilder`? And does writing the same implementation manually does not `require java.base` in the module-info.java? – Naman Sep 06 '17 at 01:32
  • 1
    I just go to souce and click generate toString() and press ok. Doesen't require StringBuffer or StringBuilder. If I type manually works fine,I don't get any error or anything. – BrunoJustino Sep 06 '17 at 13:42
  • In that case, could you also share the manual code that you write and probably try and report this to Eclipse in case this is some know issue with Eclipse itself. – Naman Sep 07 '17 at 02:55

3 Answers3

13

After a quick look I filed https://bugs.eclipse.org/521995 - i.e., it's indeed a bug in the Beta support for Java 9.

EDIT: While that particular bug is fixed only in the Photon stream (to be released in June), several other fixes in this area did get back ported. So with a bit of luck the 4.7.3a Release (with Java 10 support, scheduled for Apr. 11) should resolve this issue for most users.

Stephan Herrmann
  • 7,963
  • 2
  • 27
  • 38
1

Go to Project --> Properties --> Java Build Path at the Libraries section, see which jdk/jre is included (in my case I had Java 9 there, but the project was configured with Java 8).

If the wrong one then click Add External Jars ... from the right menu. To find the jar (if on mac) go to /Library/Java/JavaVirtualMachines, and navigate till you find the rt.jar file.

In my case the path was: /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib.

Kejsi Struga
  • 550
  • 6
  • 21
0

the same issue was happening to me when I was using Java 9, after that, I uninstalled Java 9 and later I installed JDK 1.8 and I have solved two problems one is toString() generation and (JavaDoc issue not working means no description about anything when I hover a cursor over the elements ).