0

So thanks to some very helpful people I was able to get started on coding this macro.

However I am running into tons of errors (compiling through Fiji).

First here is my code (I have no clue where there error is coming from so I'm posting all of it):

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import ij.plugin.frame.*;

public class Test_Plugin implements PlugIn {



    private void getFile(String dirPath) {
        try {
            Files.find(Paths.get(dirPath), 1, (path, basicFileAttributes) -> (path.toFile().getName().contains("DAPI"))).forEach(dapiPath) -> {
                    Path gfpPath = dapiPath.resolveSibling(dapiPath.getFileName().toString().replace("DAPI", "GFP"));
                    doSomething(dapiPath, gfpPath);
             }  
        }catch(IOException e){
             e.printStackTrace();
        }
    }


    //Dummy method does nothing yet.

    private void doSomething(Path dapiPath, Path gfpPath) {
      System.out.println(dapiPath.toAbsolutePath().toString());
      System.out.println(gfpPath.toAbsolutePath().toString());
    }

}

I'm really lost as to where the errors are coming from. I feel like I'm missing a syntax error somewhere but I cannot find it.

I checked the way that the methods are called and it seems fine to me.

Here are the errors it is throwing up:

Test Errors Test Errors

Community
  • 1
  • 1
FrankyG
  • 182
  • 7

1 Answers1

3

As you can see in the first lines of the stack trace in your screenshot, your Java code is full of syntax errors (starting from line 14).

If you really want to develop in Java, the recommended way is to use an IDE like Eclipse or Netbeans. If you open your code in one of these, you'll see a lot of warnings that you can fix even before compiling the code. Please also consider reading some Java tutorials to learn the basics.

If you don't have any experience in Java programming, I recommend using one of the scripting languages that Fiji understands. For example, you can even paste any Java code and run it as a Groovy script in the script editor without the need for compiling it.

Jan Eglinger
  • 3,995
  • 1
  • 25
  • 51
  • Thanks. I have read a good bit of Java tutorials but a lot of them are just scattered across the subjects or just end abruptly so it's become hard to connect the dots sometimes. I look at API a lot to get a handle of what the syntax should look like but I guess that only gets me so far. – FrankyG Nov 18 '15 at 15:40
  • The link to the Java tutorials already helped me narrow it down to 2 errors so thank you very much! – FrankyG Nov 18 '15 at 15:48