java - How to get current path when program is loaded dynamically -


i'm not able give question apt title apology that. making modularised application. load various jar files @ runtime , invoke particular method of particular class (of jar file) @ run time.

the jar file has supported file. jar file uses application , lets abc located in same directory have kept jar file. when run jar file

new file(".").getabsolutepath() 

gives correct path (this abc located) , program runs fine. when load jar file dynamically , invoke method using reflection above code gives path of parent program , abc not found @ path.

now question how find path in jar file exists when i'm running jar file's code using reflection.

please let me know if need more explanation.

try this:

public static void main(string[] args) {     system.out.println(stringutils.class.getresource("stringutils.class")); } 

(note: stringutils present on classpath maven dependency @ time) gives me:

jar:file:/home/******/.m2/repository/org/apache/commons/commons-lang3/3.4/commons-lang3-3.4.jar!/org/apache/commons/lang3/stringutils.class 

since class in jar file, gives me location of class file within jar.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -