I want to copy my jar file to another location… How do i do that?
Seriously, WHAT?!!?!!???!@!@!
You need to give more information, how do you want to do it? Are you using a build tool or something?
Make a jar that writes a batch file to the system, in that batch file, have your java program write:
XCOPY currentjar.jar C:/new/location
Then to run that batch file from the java code, do this
Runtime.getRuntime().exec("C:/path/to/batch");
Edit: This is off the top of my head and may or may not work
My jar file game.jar and i want to copy it to lets say appdata but how do i do it? So how do i get my jars location and how do i copy it to appdata? And must do it in java + i don’t know its location!
You should probably use some kind of installation tool that a user would run and would put files places for you, but I am not very familiar with them so maybe someone else could suggest one.
Also, you can get the location of your jar file by doing this
YourClassName.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()