0
votes

Hi i have made a 2 files that is suppose to copy file, but it makes the file url twice e.g. Users/Name/Users/Name/Desktop/jar.jar

Its adding the location of the runnable jar i opened to start then my path i want.

Code:

String path1 = System.getProperty("user.dir") + File.separator + "Desktop" + File.separator + "Coding" + File.separator + "Temp";
    File file = new File(path1);
    String path2 = System.getProperty("user.dir") + File.separator + "Library" + File.separator + "LaunchAgents" + File.separator + "program.jar";
    File file2 = new File(path2);
    if(file2.exists()) {
        logger.warning("File 3 def");
        return;
    }

    File file4 = new File(file.getAbsolutePath() + File.separator + "copied.jar");
    if(!file4.exists()) {
        logger.warning("cp " + file4.getAbsolutePath() + " : " + file2.getAbsolutePath());

        logger.warning("File 4 def");
        return;
    }

Log:

WARNING: cp /Users/myuser/Desktop/Coding/Temp/Desktop/Coding/Temp/program.jar : /Users/myuser/Desktop/Coding/Temp/Library/LaunchAgents/copied.jar

WARNING: File 4 def

1

1 Answers

0
votes

System.getProperty("user.dir") gets the current working directory. See documentation.

Perhaps you meant System.getProperty("user.home"), which gets your home directory.