S
S
sandrosklyarov2017-06-06 01:00:35
Java
sandrosklyarov, 2017-06-06 01:00:35

How to put config files and libraries inside jar?

I build the project using Maven, then I pack it into an exe using launch4j. The final exe, like jar, only works if there are two folders nearby: a folder with config files (which change!) And a folder with Maven jar dependencies.
Naturally, you don’t really want to carry both folders with you.
What can be done?
Is it really possible to change config files inside a jar somehow? It's easy to read, but to write to them ... There are two files: xml and properties
And the dependencies immediately in the main jar, how can you write it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Alexandrov, 2017-06-06
@jamakasi666

1) Do not suffer from garbage, for configs there is% APPDATA% or "user.home".
2) You can stupidly take dependencies and shove them into jar programs, i.e. open the dependency jar archiver and drag all the contents into the jar of your program.
3) A more correct option is to simply configure maven so that it packs the dependencies into the binary jar.
4) A more stupid option is to take your program and make an sfx archive that, when you click on it, will unpack somewhere in% temp% and run the program.
5) Using launch4j is even more insanity, in most cases the user is stupid and will not guess to set the Java runtime. Better Use Self-Contained Application Packaging

G
gubber, 2017-06-06
@gubber

As an option. You need to have two sets of configs, one is standard inside the jar file, the second is customizable from the outside. And then in order:
1. read the settings from the standard settings file
2. read the settings from the optional settings file.
In this case, for the settings not specified in the second file, the default values ​​will be taken.

S
sandrosklyarov, 2017-06-08
@sandrosklyarov

Yes, configs will remain external
In launch4j there is a Java download function, Java users of the application will still need Java ...
Somehow, you need to pack the dependencies inside with maven libraries, probably ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question