0
votes

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...:

  • Install OpenJDK Java 7 Runtime (lastest official JDK on Ubuntu that worked for me before);
  • Install the lastest version of Eclipse;
  • Run it from my main folder, My documents, Desktop, separate HDD and separate partition... all failed;

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!

1
That looks more like Eclipse related errors. If you type java -version and javac -version on the command line what is the output? Have you configured the SDKs in Eclipse and your project?mkobit
I had some odd issues when I use OpenJdk, then i switch to Oracle Jdk, and everything works fine.Haifeng Zhang
When I write "java -version", I get java version "1.7.0_65" OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-0ubuntu0.14.04.1) OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)The Drummer from Kubuntu
When I write "javac -version", it tells me to install some packages. I am installing them now to see what happens.The Drummer from Kubuntu

1 Answers

0
votes

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.