dimanche 11 octobre 2020

How to get the file location of a jar inside of a jar

I'm trying to get the file location of a jar inside a jar. This is the code I have that gets the location of the jar file, then I direct it to my Lib folder, and according to my code, the file location does not exit.

    private File getThisJar() {
         return new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
    }
    
    public void handle() {
         File jar = new File(getThisJar() + "/lib", "JDA.jar");
         if (!jar.exists())
             return;
    }

In this the .exists method returns false and I'm not sure exactly what I'm doing wrong.





Aucun commentaire:

Enregistrer un commentaire