| | |
Error message and this mans wits end...!
![]() |
•
•
Join Date: Apr 2008
Posts: 4
Reputation:
Solved Threads: 0
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!
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!
•
•
Join Date: Apr 2008
Posts: 4
Reputation:
Solved Threads: 0
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
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
JAVA Syntax (Toggle Plain Text)
import ij.*; import ij.process.*; // needed for ImageProcessor import ij.gui.*; import ij.io.*; // needed for Opener import ij.plugin.filter.PlugInFilter; import ij.plugin.*; // needed for plugin import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import java.io.FileInputStream; import java.io.IOException; import java.io.FileNotFoundException; public class Template_Test implements PlugIn, PlugInFilter { private GenericRecallableDialog gd; String imgAddress; public void run(String arg) { gd = new GenericRecallableDialog("Select Template from file and find matches", IJ.getInstance()); gd.addButton("1 Pence"); gd.addButton("2 Pence"); gd.addButton("5 Pence"); gd.addButton("1 Pound"); gd.showDialog(); while (!(gd.wasCanceled())) { if (gd.getFocusOwner() == null) IJ.wait(500); if (gd.getButtonValue(0)) { imgAddress = "C:\\Documents and Settings\\Garys\\Desktop\\Project\\My Project\\1pence"; IJ.showMessage("Finished.","Area is "+match(imgAddress));} if (gd.getButtonValue(1)) { imgAddress = "C:\\Documents and Settings\\Garys\\Desktop\\Project\\My Project\\2pence"; IJ.showMessage("Finished.","Area is "+match(imgAddress));} if (gd.getButtonValue(2)) { imgAddress = "C:\\Documents and Settings\\Garys\\Desktop\\Project\\My Project\\5pence"; IJ.showMessage("Finished.","Area is "+match(imgAddress));} if (gd.getButtonValue(3)) { imgAddress = "C:\\Documents and Settings\\Garys\\Desktop\\Project\\My Project\\1pound"; IJ.showMessage("Finished.","Area is "+match(imgAddress));} } public double match(String addr) { Opener o = new Opener(); o.open(addr); ImagePlus newimp = WindowManager.getCurrentImage(); IJ.run("Make Binary"); IJ.run("Fill Holes"); IJ.run("Analyze Particles...", "size=1000-9999999 circularity=0.00-1.00 show=Nothing display clear summarize record"); IJ.saveAs("Measurements", "C:\\Documents and Settings\\Garys\\Desktop\\Project\\My Project\\Results.xls"); try { POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("Results.xls")); HSSFWorkbook hssfworkbook = new HSSFWorkbook(fs); HSSFSheet sheet = hssfworkbook.getSheetAt(0); HSSFCell currentStateCell = null; HSSFRow currentRow = sheet.getRow(1); currentStateCell = currentRow.getCell((short)1); double area = currentStateCell.getNumericCellValue(); } catch(FileNotFoundException fnfe) { System.out.println("File Results not found.");} catch(IOException ioe) { System.out.println("Unable to read from Results");} return area; } } }
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
Does
Try to find the end of the while loop and the run() method. I think you'll find your brace problem.
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.
Lines 74 to 84:
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:
Java Syntax (Toggle Plain Text)
catch(FileNotFoundException fnfe) { System.out.println("File Results not found.");} catch(IOException ioe) { System.out.println("Unable to read from Results");} return area; }
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:
Java Syntax (Toggle Plain Text)
if () { if () { for (;;) { } while () { } } else { } }
Check out my New Bike at my Public Profile at the "About Me" tab
![]() |
Other Threads in the Java Forum
- Previous Thread: Accessing a file on a pda, from a midlet
- Next Thread: Font problem
| Thread Tools | Search this Thread |
-xlint add android api applet application applications array arrays automation bank bi binary blackberry bluetooth chat class client code compile compiler component database development digit eclipse equation error event fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image infinite input int integer j2me java javame javaprojects jetbrains jni jpanel jtable julia learningresources linux list login loop main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying pearl problem program programming project qt recursion scanner screen scrollbar server set sms sort sorting spamblocker sql sqlserver string superclass swing system text-file thread threads tree variablebinding windows xor






