If I have a constructor that requires a path to a file, how can I “fake” that if it is packaged into a jar?

前端 未结 6 1463
半阙折子戏
半阙折子戏 2020-12-17 05:09

The context of this question is that I am trying to use the maxmind java api in a pig script that I have written... I do not think that knowing about either is necessary to

6条回答
  •  被撕碎了的回忆
    2020-12-17 05:38

    Use the classloader.getResource(...) method to do the file lookup in the classpath, which will pull it from the JAR file.

    This means you will have to alter the existing code to override the loading. The details on how to do that depend heavily on your existing code and environment. In some cases subclassing and registering the subclass with the framework might work. In other cases, you might have to determine the ordering of class loading along the classpath and place an identically signed class "earlier" in the classpath.

提交回复
热议问题