Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Oxygen generate toString generation not working

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?

like image 488
BrunoJustino Avatar asked Sep 06 '17 00:09

BrunoJustino


2 Answers

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.

like image 92
Stephan Herrmann Avatar answered Sep 26 '22 19:09

Stephan Herrmann


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.

like image 41
Kejsi Struga Avatar answered Sep 24 '22 19:09

Kejsi Struga