As the title underlines it, I am having trouble with the Java compiler for Ubuntu. I did a fresh install of the OS. Before uninstalling Ubuntu, a few months ago, Eclipse's Java compiler worked like a charm. I followed the exact same steps...:
I think it has something to do with the compiler... I use Java 1.8 (the same as my Windows 8.1 compiler that works very well too). I remember exactly also that it was the same as the one I had a few months ago.
I am getting compiler errors in a main method (System.out.println(), String, double, etc.) and I would like to resolve this a fast as possible.
Here is an exhaustive list of the errors I am getting:
import java.util.*;
public class StackOverFlow {(...code...)} [Implicit super constructor Object() is undefined for defaults constructor. Must define a apecific constructor] S
String(...); [String cannot be resolved to a type]
Scanner (...); [Scanner cannot be revolved to a type]
System.out.println(...); [System cannot be resolved]
System.in ; [System cannot be resolved to a variable]
Do I need to enable/disable some settings? Do I need to install or copy/create additional files? Anything else?
All help is highly appreciated.
Thank you!
I finally found a solution to my problem.
My problem was that I was using a different JRE version compared to the one I was supposed to use alongside the version of OpenJDK I installed. Eclipse assumed that the right JRE would be Java-1.8. It was wrong, so here is what I did.
I selected my project, right clicked on it, went to "Properties". Then, on "Java Build Path", I went on the "Libraries" tab and edited my JRE compiler (clicked on "Edit" button). I finally selected the default workspace default JRE, "Workspace default JRE (...)".
That fixed everything.
I hope it helps someone else.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.