Java, several cans or one big?

As for memory efficiency and usage, is it better to have one big jar with a class / package for each function as needed? Or is it better to split it into smaller, more manageable banks instead?

Let's say I have a large project with 20-30 packages that are not related to each other:

com.example.test - class 1 - class 2 - class 3 - another.package - class 1 - class 2 - class 3 - another.package - class 1 - class 2 - class 3 - another.package - class 1 - class 2 - class 3 

Instead, would it be more efficient to split each package into its own jar? And there are several, smaller, lighter cans? I’m not sure that it even matters, but I’m curious because it would facilitate further development if I were a little upset. (in the absence of performance flaws)

+7
java
source share
1 answer

If packets are not related to each other, they should not be in the same jar period.

When disassembling a jar, users can choose which packages they need during deployment and include only those that have nothing more.

You want to deploy the smallest possible code. Something extra - an additional potential problem, mistake, security hole. Unnecessary things can also slow down the class loader, although this is a tiny concern compared to the others I mentioned earlier.

If some of them or all of them are always used together, then for practical reasons it is quite possible to combine them together.

+11
source share

All Articles