We have a suit of application which have some common .Jar files. While installing each app these files are copied to each application's folder. This results in wastage of storage space and also it is tedious to keep the files in sync. Does java provide any way to share .jars? Like in windows we can copy .dll file in \windows\system32 and it is available to all apps.
If the two apps are on the same machine, you can put/deploy the jars in one folder.
Then both apps can pick/load the jars at runtime from that shared folder. This is doable.
Say your folder is:
/some/folder/
And the jars there are
a.jar
b.jar
c.jar
Then just add
/some/folder/a.jar
/some/folder/b.jar
/some/folder/c.jar
to the classpaths of both apps (in the two apps' startup scripts).
But there's no one single pre-defined place on OS level
to put those into (like \Windows\System32 let's say)
so that all Java apps on that machine pick their jars from
there. And I find this a very good thing. So things are not
quite the same as with DLLs (the example you give).
There are a few options:
You can use something like Maven, which will manage the JAR files for you.
You can create a library folder and reference this to the projects you've got.
If you're using Eclipse, you can create shared user libraries (read more here).
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With