Make sure that the JDK from Eclipse matches the JDK of the model preferences.
Regards,
Ronald
[EDIT] May be I have misread your question. I have checked the javodocs, and I am not sure what you want to achieve in the Java code. Try to take a look at the documentation here: https://apidocs.mendix.com/6/runtime/ You may be trying to use something that is not available.
Always does the trick for me :)
Have you tried following this tutorial?
https://world.mendix.com/display/refguide6/Using%20Eclipse
I am having the same problem. Reinstall the Eclipse J2EE version with the .exe format installation file solved my problem.