Error message and this mans wits end...!

Reply

Join Date: Apr 2008
Posts: 4
Reputation: DickLaurent is an unknown quantity at this point 
Solved Threads: 0
DickLaurent DickLaurent is offline Offline
Newbie Poster

Error message and this mans wits end...!

 
0
  #1
Apr 19th, 2008
Hello, here goes.

I am receiving the following three errors when compiling my new template matching plug-in in imagej

C:\Program Files\ImageJ\plugins\Template_Test.java:61: '}' expected.
}
^
C:\Program Files\ImageJ\plugins\Template_Test.java:63: Statement expected.
public double match(String addr)
^
C:\Program Files\ImageJ\plugins\Template_Test.java:93: Class or interface declaration expected.
}
^
3 errors, 1 warning

I'm pretty sure (after many checks) that all curly brackets are placed correctly, and there are the right number of them in the code.

Could anybody advise me what might cause this error. If it would help for me to post my coding up then I will, but for reasons of brevity I will leave it for now in the hope that there are only a few reasons for me receiving these errors and that you knowledgeable helpful and damn right good looking people can inform me of those possibilities.

Thank you!
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Error message and this mans wits end...!

 
0
  #2
Apr 19th, 2008
well, quite obviously there's something wrong with your code that causes your braces to NOT line up correctly.
So fix your code.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,439
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 510
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Error message and this mans wits end...!

 
0
  #3
Apr 19th, 2008
Yep, you are still missing the close of some block or expression. Check the braces, semi-colons, and parenthesis in the code above the public double match(String addr) line.

Strict adherence to proper indentation will help a lot in seeing structural errors like this.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 3,584
Reputation: jasimp has a spectacular aura about jasimp has a spectacular aura about jasimp has a spectacular aura about 
Solved Threads: 52
Featured Poster
jasimp's Avatar
jasimp jasimp is offline Offline
Senior Poster

Re: Error message and this mans wits end...!

 
0
  #4
Apr 19th, 2008
EDIT: Ezzaral was too fast for me
Last edited by jasimp; Apr 19th, 2008 at 12:32 pm.
"Argyou not with the hand you are dealt in cards or life." ---- Wizard and Glass
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 4
Reputation: DickLaurent is an unknown quantity at this point 
Solved Threads: 0
DickLaurent DickLaurent is offline Offline
Newbie Poster

Re: Error message and this mans wits end...!

 
0
  #5
Apr 19th, 2008
OK, I have trawled through all the code and I just can not see the problem. No missing semi-colons or misplaced curly-parenthesis. I really don't know where else to look. I am a relative beginner looking for help. Here is the code. (I have altered the code since last post so errors have moved to different lines, error message is underneath code). Since I have until Monday to get this sorted I thought this was the best place to come. Sorry If it seems a bit primitive

  1. import ij.*;
  2. import ij.process.*; // needed for ImageProcessor
  3. import ij.gui.*;
  4. import ij.io.*; // needed for Opener
  5. import ij.plugin.filter.PlugInFilter;
  6. import ij.plugin.*; // needed for plugin
  7. import org.apache.poi.hssf.usermodel.HSSFCell;
  8. import org.apache.poi.hssf.usermodel.HSSFRow;
  9. import org.apache.poi.hssf.usermodel.HSSFSheet;
  10. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  11. import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  12. import java.io.FileInputStream;
  13. import java.io.IOException;
  14. import java.io.FileNotFoundException;
  15.  
  16.  
  17. public class Template_Test implements PlugIn, PlugInFilter
  18. {
  19. private GenericRecallableDialog gd;
  20. String imgAddress;
  21.  
  22. public void run(String arg)
  23. {
  24. gd = new GenericRecallableDialog("Select Template from file and find matches", IJ.getInstance());
  25. gd.addButton("1 Pence");
  26. gd.addButton("2 Pence");
  27. gd.addButton("5 Pence");
  28. gd.addButton("1 Pound");
  29. gd.showDialog();
  30.  
  31. while (!(gd.wasCanceled()))
  32. {
  33. if (gd.getFocusOwner() == null) IJ.wait(500);
  34. if (gd.getButtonValue(0))
  35. {
  36. imgAddress = "C:\\Documents and Settings\\Garys\\Desktop\\Project\\My Project\\1pence";
  37. IJ.showMessage("Finished.","Area is "+match(imgAddress));}
  38.  
  39. if (gd.getButtonValue(1))
  40. {
  41. imgAddress = "C:\\Documents and Settings\\Garys\\Desktop\\Project\\My Project\\2pence";
  42. IJ.showMessage("Finished.","Area is "+match(imgAddress));}
  43.  
  44. if (gd.getButtonValue(2))
  45. {
  46. imgAddress = "C:\\Documents and Settings\\Garys\\Desktop\\Project\\My Project\\5pence";
  47. IJ.showMessage("Finished.","Area is "+match(imgAddress));}
  48.  
  49. if (gd.getButtonValue(3))
  50. {
  51. imgAddress = "C:\\Documents and Settings\\Garys\\Desktop\\Project\\My Project\\1pound";
  52. IJ.showMessage("Finished.","Area is "+match(imgAddress));}
  53. }
  54.  
  55. public double match(String addr)
  56. {
  57. Opener o = new Opener();
  58. o.open(addr);
  59. ImagePlus newimp = WindowManager.getCurrentImage();
  60. IJ.run("Make Binary");
  61. IJ.run("Fill Holes");
  62. IJ.run("Analyze Particles...", "size=1000-9999999 circularity=0.00-1.00 show=Nothing display clear summarize record");
  63. IJ.saveAs("Measurements", "C:\\Documents and Settings\\Garys\\Desktop\\Project\\My Project\\Results.xls");
  64. try
  65. {
  66. POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("Results.xls"));
  67. HSSFWorkbook hssfworkbook = new HSSFWorkbook(fs);
  68. HSSFSheet sheet = hssfworkbook.getSheetAt(0);
  69. HSSFCell currentStateCell = null;
  70. HSSFRow currentRow = sheet.getRow(1);
  71. currentStateCell = currentRow.getCell((short)1);
  72. double area = currentStateCell.getNumericCellValue();
  73. }
  74.  
  75. catch(FileNotFoundException fnfe)
  76. {
  77. System.out.println("File Results not found.");}
  78.  
  79. catch(IOException ioe)
  80. {
  81. System.out.println("Unable to read from Results");}
  82.  
  83. return area;
  84. }
  85. }
  86. }

ERRORS:
C:\Program Files\ImageJ\plugins\Template_Test.java:53: '}' expected.
}
^
C:\Program Files\ImageJ\plugins\Template_Test.java:55: Statement expected.
public double match(String addr)
^
C:\Program Files\ImageJ\plugins\Template_Test.java:86: Class or interface declaration expected.
}
^
3 errors, 1 warning
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,439
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 510
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Error message and this mans wits end...!

 
0
  #6
Apr 19th, 2008
Does gd.getButtonValue(1) return a boolean value? Because Java doesn't evaluate such expression like C++ and some other languages where a non-zero value is true. It needs to be an actual boolean result expression.

Try to find the end of the while loop and the run() method. I think you'll find your brace problem.
Last edited by Ezzaral; Apr 19th, 2008 at 12:53 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 4
Reputation: DickLaurent is an unknown quantity at this point 
Solved Threads: 0
DickLaurent DickLaurent is offline Offline
Newbie Poster

Re: Error message and this mans wits end...!

 
0
  #7
Apr 19th, 2008
gd.GetButtonValue is a function allowed inside ImageJ (the java based image processing package for which I am creating this class). That has compiled and worked fine in an earlier draft. Its only since I coded the match() method!
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,660
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 224
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: Error message and this mans wits end...!

 
0
  #8
Apr 19th, 2008
Lines 74 to 84:
  1. catch(FileNotFoundException fnfe)
  2. {
  3. System.out.println("File Results not found.");}
  4. catch(IOException ioe)
  5. {
  6. System.out.println("Unable to read from Results");}
  7. return area;
  8. }
As you can see you are missing a bracket. And here is a tip for the future.
Whenever you open a bracket immediately close it, and them start writing code inside it. If keep opening and writing code, then there is no way to remember of find where to close.
And I hope that you leave tabs when you open brackets:

  1. if () {
  2. if () {
  3. for (;;) {
  4.  
  5. }
  6. while () {
  7.  
  8. }
  9. } else {
  10.  
  11. }
  12. }
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,439
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 510
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Error message and this mans wits end...!

 
0
  #9
Apr 19th, 2008
The entire match() function is defined within the run() function. There are enough braces to go around I believe - you just can't define functions within functions.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 4
Reputation: DickLaurent is an unknown quantity at this point 
Solved Threads: 0
DickLaurent DickLaurent is offline Offline
Newbie Poster

Re: Error message and this mans wits end...!

 
0
  #10
Apr 19th, 2008
Ezzaral! Thank you so much. I was certain all brackets were accounted for. Can't believe I didn't realise I'd defined the method in the run block.
Well, I have a couple of new errors, but Ill give em a good look before crying for help.

Thanks for the replies people

Take care!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC