dimanche 16 août 2015

How to get current path when program is loaded dynamically

I'm not able to give this question an apt title so apology for that. I am making a modularised application. I load various jar files at runtime and invoke particular method of a particular class (of the jar file) at run time.

The jar file has some supported file. Now my jar file uses another application , lets say abc which is located in the same directory where i have kept the jar file. When i run the jar file then

new File(".").getAbsolutePath()

gives the correct path (this is where abc is located) and program runs fine. But when i load this jar file dynamically and invoke method using reflection above code gives the path of the parent program and abc is not found at that path.

Now my question is how do i find the path in which my jar file exists when i'm running my jar file's code using reflection.

Please let me know if you need more explanation.





Aucun commentaire:

Enregistrer un commentaire