this.getClass().getResource(“”).getPath() returns an incorrect path
问题 I am currently making a small simple Java program for my Computer Science Final, which needs to get the path of the current running class. The class files are in the C:\2013\game\ folder. To get this path, I call this code segment in my main class constructor: public game(){ String testPath = this.getClass().getResource("").getPath(); //Rest of game } However, this command instead returns this String: "/" despite the correct output being "C:/2013/game" Additionally, I attempted to rectify