I am trying to add my APP to startup folder.
public class info {
    
    public static String getautostart() {
        return System.getProperty("java.io.tmpdir").replace("Local\\Temp\\", "Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup");
    }
    
    public static String gettemp() {
        String property = "java.io.tmpdir";
        String tempDir = System.getProperty(property);
        return tempDir;
    }
    
    public static String getrunningdir() {
        String runningdir = ProjectGav.class.getProtectionDomain().getCodeSource().getLocation().getPath();
        return runningdir;
    }
    
}
That's the class I store info methods
And the main class:
    System.out.println(info.getautostart() + "\\asdf.jar");
    System.out.println(info.getrunningdir());
    Files.move(info.getrunningdir(), info.getautostart() + "\\asdf.jar");
This is the output from println:
C:\Users\JOHNDO~1\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\asdf.jar
/C:/Users/John%20Doe/Downloads/project1.jar
The files.move is not working.
                        
OK lets say you want to move your jar from the current directory to the autostart folder. You already have these methods:
Now moving a file needs
Pathsand notStringso you need to create a Path instance for each of your Strings:If you want to point to a file (like your
.jarfile) within the paths you can do this:All together the
moveshould look like this: