[Updated, sorry about the change but now to the real problem] I cannot include try-catch-loop there for the exception from the method getCanonicalPath(). I trie
public static final String startingPath = (new File(".")).getCanonicalPath();
You are missing the type of variable startingPath
startingPath