0

I am a bit unsure of the correct way to ask this, but how would I get the file path of the jar file I'm executing within the file? I want to make the program write information to a text file that is created in the same location as the .jar file, but I'm unsure of how to go about doing this. I'm aware this might be a duplicate question, but most of the answers on similar questions aren't clear enough for my specific problem.

Alex
  • 9
  • 4
  • Just to clarify - you are looking to create and write to a file in the same directory as your jar file? You wouldn't care about the path if you could write the file without it? – Daniel Bickler May 15 '17 at 19:15
  • Possible duplicate of [How to get the path of a running JAR file?](http://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-running-jar-file) – Daniel Bickler May 15 '17 at 19:18
  • 1
    This is an [XY problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem/66378#66378). You should not be trying to use the directory where the .jar file resides. Instead, use a known location under the user’s home directory. See http://stackoverflow.com/questions/35388882/find-place-for-dedicated-application-folder . – VGR May 15 '17 at 19:30
  • @DanielBickler Yeah, that sounds correct. My current program uses a filepath to make a file but if I could just write it to the same directory without the filepath that would work – Alex May 15 '17 at 19:30

0 Answers0