0

I have a java program and I want it to be able to print out its location on the computer. For example, if I were to place the program in the Downloads folder, and run it, it would print out the path to the file.

1

1 Answer 1

1
new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation()
.toURI()).getPath();

make sure to change the Myclass.class stuff

then system.out.println(File)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.