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!

well, quite obviously there's something wrong with your code that causes your braces to NOT line up correctly.
So fix your code.

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.

EDIT: Ezzaral was too fast for me ;)

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

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

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!

Lines 74 to 84:

catch(FileNotFoundException fnfe)
{
   System.out.println("File Results not found.");}
catch(IOException ioe)
{
   System.out.println("Unable to read from Results");}
   return area;
}

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:

if () {
    if () {
         for (;;) {

         }
         while () {

         }
    } else {

    }
}

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.

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.