[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
Just initialize it in the static block(the variable is final). You can't catch exceptions on declaring a variable.