public static File getRunningLocation ( ) throws Exception { String codePath = FileUtil . class . getProtectionDomain ( ) . getCodeSource ( ) . getLocation ( ) . getPath ( ) ; String decodedPath = URLDecoder . decode ( codePath , "UTF-8" ) ; File codeFile = new File ( decodedPath ) ; if ( ! codeFile . exists ( ) ) { throw new Exception ( "Cannot locate running location of JBake!" ) ; } File codeFolder = codeFile . getParentFile ( ) . getParentFile ( ) ; if ( ! codeFolder . exists ( ) ) { throw new Exception ( "Cannot locate running location of JBake!" ) ; } return codeFolder ; }
Works out the folder where JBake is running from .