0

We are in a problem in which we are reading a folder inside a project For that we have kept the folder inside the resource folder

src\main\resource\plugins

we need to find the path of the plugin folder inside the resource folder . When running from eclipse below code is working but when the same is invoked with jar then not able to run

String path =  XYZClass.class.getClassLoader().getResource("plugins").getFile();

it is able to find the path in eclipse but when running fron jar it not able to recognize it and when i print the path as coming on console

D:/Workarea/text/lib/xyx-3.2.3.1-SNAPSHOT.jar!/plugins

SarthAk
  • 1,628
  • 3
  • 19
  • 24
  • 1
    Does replacing `plugins` with `/plugins` work? Refer to [this SO](http://stackoverflow.com/questions/2593154/get-a-resource-using-getresource) discussion – Raghuram Apr 17 '15 at 06:01

1 Answers1

1

During the process-resources life cycle phase the content which is located in src/main/resources will be copied into target/classes folder. The result is that the resource is accessible under /plugins casae the / is the root folder of the jar which in result will be packaged later.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235