Public class rtumain {public static void main (string [] ARGs) {system. out. println (getprojectpath (); system. out. println (getrealpath ();} public static string getprojectpath () throws unsupportedencodingexception {URL url = rtumain. class. getprotectiondomain (). getcodesource (). getlocation (); string filepath = urldecoder. decode (URL. getpath (), "UTF-8"); If (filepath. endswith (". jar ") {filepath = filepath. substring (0, filepath. lastindexof ("/") + 1);} file = new file (filepath); filepath = file. getabsolutepath (); Return filepath;} public static string getrealpath () {string realpath = rtumain. class. getclassloader (). getresource (""). getFile (); file = new file (realpath); realpath = file. getabsolutepath (); try {realpath = urldecoder. decode (realpath, "UTF-8");} catch (exception e) {e. printstacktrace () ;}return realpath ;}}