The clue is in the error message:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown at scannertest.ScannerTest.main(ScannerTest.java:13)
What it means is that Scanner constructor throws an exception, so you need to place it in try/catch block, like so:
import java.io.*;
import java.util.Scanner;
public class ScannerTest {
public static void main(String[] args) {
//try block starts here
try {
File f = new File (new File("SPY.txt").getAbsolutePath());
System.out.println(f.exists());
Scanner s = new Scanner(f);
}
//catch the exception
catch(FileNotFoundException e) {
e.printStackTrace();
}
}
}