Search code examples
javajarfile-copying

Make jar file copy itself


I am trying to make my main executable jar file copy itself to another location.

How can I do this?


Solution

  • return new File(MyClass.class.getProtectionDomain().
     getCodeSource().
     getLocation().
     getURI().
     getPath()).getName();
    

    will return a full name