为了账号安全,请及时绑定邮箱和手机立即绑定

打印当前工作班级的班级路径

打印当前工作班级的班级路径

达令说 2021-08-19 13:31:47
第二个答案来自: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 System1 error有人可以帮助我如何使用以下命令打印类路径:final File f = new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath());
查看完整描述

1 回答

?
陪伴而非守候

TA贡献1757条经验 获得超8个赞

你需要一个资本P

System.getProperty(...)


查看完整回答
反对 回复 2021-08-19
  • 1 回答
  • 0 关注
  • 149 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信