Bellow is my code, when i run these code in IDE it works well, but when i run in dos command it gives me an error of NullPointException. Please give me a hand. thanks!
//first get the classLoader
ClassLoader classLoader = TestMainPath.class.getClassLoader();
//show message
System.out.println("loader=" + classLoader);
//
URL r = classLoader.getResource("TestMainPath/TestMainPath.class");
System.out.println("r=" + r);
String mainPath =r.getPath();
System.out.println(mainPath);
File sf = new File(mainPath + "/main/newfile");
System.out.println(sf.getPath());
System.out.println(sf.exists());