正在打印 Class 当前工作路径 class
Printing Class path of the current working class
第二个答案来自: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");
}
}
但它抛出这个错误:
HelloWorld.java:6: error: cannot find symbol
System.getproperty("java.class.path");
^
symbol: method getproperty(String)
location: class System
1 error
有人可以帮助我如何使用命令打印 class 路径:
final File f = new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath());
你需要大写P
:
System.getProperty(...)
第二个答案来自: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");
}
}
但它抛出这个错误:
HelloWorld.java:6: error: cannot find symbol
System.getproperty("java.class.path");
^
symbol: method getproperty(String)
location: class System
1 error
有人可以帮助我如何使用命令打印 class 路径:
final File f = new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath());
你需要大写P
:
System.getProperty(...)