0

The second answer from: How to get the path of running java program says I can use:

System.getProperty("java.class.path")"

So I tried it:

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");
    }
}

But it throws me this error:

HelloWorld.java:6: error: cannot find symbol
                System.getproperty("java.class.path");
                      ^
  symbol:   method getproperty(String)
  location: class System
1 error

Can someone help me how to get to print the class path beside using the command:

final File f = new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath());
Joe Iddon
  • 20,101
  • 7
  • 33
  • 54

1 Answers1

2

You need a capital P:

System.getProperty(...)
Joe Iddon
  • 20,101
  • 7
  • 33
  • 54