Ok, I found the problem I was having.

It happens that the PropertiesUserManager class already manages the case
for resources, and reads them as Streams.

I was doing that part myself, getting the resource, transforming that to a
File and giving it to the PropertiesUserManagerFactory.

So by simply passing a Plain Java File object with the partial path of the
resource to the factory, my app work nicely distributed as a Jar file.

El dom, 25 jul 2021 a las 10:25, Jesús Gómez (<jgo...@gmail.com>) escribió:

> Hi!
>
> Question?
> Can we pass an InputStream to PropertiesUserManagerFactory.setFile instead
> of a file?
> Or do we have an alternative to that setFile method?
>
> The problem is that resources can't be treated as Files when they are
> inside a Jar file.
>
> Everywhere I read and look about this, it seems that when using a jar, you
> can't refer to the resources as files, and every answer says the same: Use
> `getSourceAsStream`.
>
> This article is the best explanation I've found[1]:
> """
> In Java, we can use getResourceAsStream or getResource to read a file or
> multiple files from a resources folder or root of the classpath.
>
> The getResourceAsStream method returns an InputStream.
>
> The getResource method returns an URL and normally convert it to a File;
> Not working in JAR file.
> """
>
> [1] https://mkyong.com/java/java-read-a-file-from-resources-folder/
>

Reply via email to