Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » [Solved]At my wit's end to correct the error messages in Eclipse
[Solved]At my wit's end to correct the error messages in Eclipse [message #1770978] Sun, 20 August 2017 11:37 Go to next message
RajibKumar Bandopadhyay is currently offline RajibKumar BandopadhyayFriend
Messages: 58
Registered: July 2014
Member
Five Files in compressed format attached as New_CalculatorModel.tar.gz.
The codes were taken from `Learn Java in a Weekend` by `Joseph Russell`.
All of these files show errors in Eclipse and don't appear to compile in Eclipse, but all except one compile at the terminal with Javac filename.java
That one, CalculatorHelperTest.java , shows the following error messages and doesn't compile, even from the terminal.
javac CalculatorHelperTest.java
CalculatorHelperTest.java:11: cannot find symbol
symbol  : method setOperand1(double)
location: class CalculatorHelper
calcHelper.setOperand1(a);
          ^
CalculatorHelperTest.java:12: cannot find symbol
symbol  : method setOperand2(double)
location: class CalculatorHelper
calcHelper.setOperand2(b);
          ^
CalculatorHelperTest.java:13: add() has private access in CalculatorHelper
System.out.println(a + " + " + b + " = " + calcHelper.add());
                                                     ^
CalculatorHelperTest.java:14: subtract() has private access in CalculatorHelper
System.out.println(a + " - " + b + " = " + calcHelper.subtract());
                                                     ^
CalculatorHelperTest.java:15: multiply() has private access in CalculatorHelper
System.out.println(a + " * " + b + " = " + calcHelper.multiply());
                                                     ^
CalculatorHelperTest.java:16: divide() has private access in CalculatorHelper
System.out.println(a + " / " + b + " = " + calcHelper.divide());
                                                     ^
6 errors


My master, Dr. Merks, please advise.

[Updated on: Wed, 23 August 2017 11:51]

Report message to a moderator

Re: At my wit's end to correct the error messages in Eclipse [message #1771000 is a reply to message #1770978] Mon, 21 August 2017 04:21 Go to previous messageGo to next message
RajibKumar Bandopadhyay is currently offline RajibKumar BandopadhyayFriend
Messages: 58
Registered: July 2014
Member
Although the author doesn't say so, let alone explicitly, I figured that I should remove the file CalculatorHelperTest.java and recompile from the terminal. I did so and then ran from the terminal. The program ran!
My version of Java in the console:
$ java -version
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.5) (6b27-1.12.5-1)
OpenJDK Client VM (build 20.0-b12, mixed mode, sharing)

But the files don't compile from the Eclipse IDE.
Why is this so?
Re: At my wit's end to correct the error messages in Eclipse [message #1771045 is a reply to message #1771000] Mon, 21 August 2017 12:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31152
Registered: July 2009
Senior Member
It's not another strange unicode character that looks like a . but is something else is it?
Re: At my wit's end to correct the error messages in Eclipse [message #1771070 is a reply to message #1771045] Mon, 21 August 2017 16:28 Go to previous messageGo to next message
RajibKumar Bandopadhyay is currently offline RajibKumar BandopadhyayFriend
Messages: 58
Registered: July 2014
Member
No, Sir! I checked with find/replace and every time I press "Replace All" it keeps on replacing, meaning both the stop marks are identical. Wlll you please check the codes in Eclipse?
Re: At my wit's end to correct the error messages in Eclipse [message #1771074 is a reply to message #1771070] Mon, 21 August 2017 17:16 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 562
Registered: August 2014
Senior Member
Please check your own code.

CalculatorHelper does not have methods SetOperand1() and SetOperand2().

The other error stem from attempts to access private methods from outside.


--

Tauno Voipio
Re: At my wit's end to correct the error messages in Eclipse [message #1771219 is a reply to message #1771074] Wed, 23 August 2017 06:13 Go to previous messageGo to next message
RajibKumar Bandopadhyay is currently offline RajibKumar BandopadhyayFriend
Messages: 58
Registered: July 2014
Member
Dr. Merks, I have updated the CalculatorModel.java as instructed in the book. I recompiled individually the four files from the terminal with OpenJDK into class files. The two files, CalculatorTest.class and CalculatorModelStateTest.class run when invoked from the terminal!
But Eclipse Console shows this error message:
Exception in thread "main" java.lang.NoSuchMethodError: main literally in Red!
Now I got a clue when I ran the other two Terminal-OpenJDK compiled files, CalculatorModel.class and CalculatorHelper.class. In either of the cases, the error messages are displayed in the console:
workspace/CalculatorModel$ java CalculatorModel

Exception in thread "main" java.lang.NoSuchMethodError: main
workspace/CalculatorModel$ java CalculatorHelper

Exception in thread "main" java.lang.NoSuchMethodError: main

So what I figured is that Eclipse runs simultaneously all the four files and then shows the first error message and then the Eclipse console is exited. A snapshot is here:index.php/fa/30461/0/

So how to individually compile the four files in eclipse (like I do in the Terminal with OpenJDK) and then run only the executable files from the source .java files that have main() functions ?

I attached both the Source Java files Latest_CalculatorModel.tar.gz as well as the Class files CalculatorModel.class.tar.gz compiled from terminal using OpenJDK.

I also give a snapshot of the Eclipse Side pane and the error message.

Dr. Merks, I was editing when you posted.

[Updated on: Wed, 23 August 2017 06:40]

Report message to a moderator

Re: At my wit's end to correct the error messages in Eclipse [message #1771229 is a reply to message #1771219] Wed, 23 August 2017 06:26 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31152
Registered: July 2009
Senior Member
In the IDE you can bring up the context menu within the editor on the Java file in the outline and invoke "Run As -> Java Application". That will of course only work on classes has have a main method. I don't know of any way to run multiple Java Applications at once.
Re: At my wit's end to correct the error messages in Eclipse [message #1771230 is a reply to message #1771229] Wed, 23 August 2017 06:34 Go to previous messageGo to next message
RajibKumar Bandopadhyay is currently offline RajibKumar BandopadhyayFriend
Messages: 58
Registered: July 2014
Member
Dr. Merks, I was editing when you replied. So could you please go back?

Quote:
In the IDE you can bring up the context menu within the editor on the Java file in the outline and invoke "Run As -> Java Application".

Okay! This part was actually followed since way back, the first time I was told!

Quote:
That will of course only work on classes has have a main method. I don't know of any way to run multiple Java Applications at once.

Okay! This part is understood!

Then why are those error messages, java.lang.NoSuchMethod occurring and being shown when I invoke 'Run'?

[Updated on: Wed, 23 August 2017 06:55]

Report message to a moderator

Re: At my wit's end to correct the error messages in Eclipse [message #1771235 is a reply to message #1771230] Wed, 23 August 2017 08:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31152
Registered: July 2009
Senior Member
Your files still have error markers on them, in the picture you showed. You can't run what you haven't compiled correctly.
[Solved]Re: At my wit's end to correct the error messages in Eclipse [message #1771247 is a reply to message #1771235] Wed, 23 August 2017 10:29 Go to previous message
RajibKumar Bandopadhyay is currently offline RajibKumar BandopadhyayFriend
Messages: 58
Registered: July 2014
Member
Yes, my query is: Why? I have followed the book! I have carefully removed and replaced all the doubtful punctuation marks. Okay, I will check thoroughly once more!

But then why is OpenJDK allowing the files to run?


[Later]
This part gave me the clue. The console registered:
Console
The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project CalculatorModel Unknown Java Problem
I had built the CalculatorModel folder manually within the Eclipse workspace folder, and did not place the source codes within the src folder, and so the .classpath file was not built.

Built an src folder and moved all the sources to that folder. Studied and copied a .classpath file from another project in the CalculatorModel folder. And the problem was resolved!

[Updated on: Sat, 26 August 2017 07:44]

Report message to a moderator

Previous Topic:Installing Eclipse for use by multiple users in a domain environment
Next Topic:Stdin in PyDev (Eclipse)
Goto Forum:
  


Current Time: Thu May 28 05:44:26 GMT 2020

Powered by FUDForum. Page generated in 0.03594 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top