java - How to give relative path in a executable jar? -


i have spring app deploying .jar.

the app has write folder located in /src (precisely /src/main/resources/patches). have path directly in code.

in application.properties: patch_dir = src/main/resources/patches

the app has read json file src/main/resources/myjson.json, path being directly written in code.

prior deploying, while running ide goes well, app sees file , folder , reads , writes correctly.

after building .jar paths change, file located in myjar.jar/boot-if/classes/myjson.json , folder respectively in myjar.jar/boot-if/classes/patches.

how can specify these paths in code in way after building jar stay relevant application?


edit: can specify path of file as: patchapplication.class.getclassloader().getresource("myjson.json").getpath();

this should solve problem, path relative class , not root of project, not improve anything.

you should specify path in file system,instead of path inside .jar.when run app ,it access given path.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -