第二個(gè)答案來自:How to get the path of running java program說我可以使用:System.getProperty("java.class.path")"所以我試了一下:class HelloWorld { public static void main(String[] args) { // Prints "Hello, World" to the terminal window. System.out.println("Hello, World"); System.getproperty("java.class.path"); }}但它拋出了我這個(gè)錯(cuò)誤:HelloWorld.java:6: error: cannot find symbol System.getproperty("java.class.path"); ^ symbol: method getproperty(String) location: class System1 error有人可以幫助我如何使用以下命令打印類路徑:final File f = new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath());
添加回答
舉報(bào)
0/150
提交
取消