Paul Clapham wrote:Do you mean you want the current working directory, or the directory where the executable jar is located? It might also help to explain why you need to find whichever of those two things you meant, as this is quite likely a question based on some decision you already made. It's possible that was a bad decision.
I mean the directory where the executable jar is located.
I would like to do this:
I have a file that I put in the package I'm using;
I would like to copy that file in another location.
So the problem is this one:
when I export my classes in a jar file and I execute it on another computer, the path of the file is no more the same.
Indeed I would like to use the path of this file in a portable way; also after the packaging a jar.
So I'm thing about how to have the absolute path of the running jar, and then the path of the file in it.
The better solution I found until now is this one:
where MyClass is my class name.
In this way I have the absolute path of the class running (or of the jar file).
But I don't have yet any reference to the file packed into the jar.
In addition I would like to parametrize"MyClass" in a way that I don't have to typing the name of the class.
Any help? :banghead: