문제

I am using java instrumentation. Given the class name (which is being instrumented), how can I know the jar file it is in?

도움이 되었습니까?

해결책

The following code should work. I tried it with a single jar and it gave me the jar path:

new File(Test.class.getProtectionDomain().getCodeSource().getLocation().getFile())

Just replace Test by your class name.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top