Decoupling Arduino's power supply
In my case the length of the wire between caps and Arduino's DC jack will be about 5cm. Is it gonna work or this setup will be useless?


It is not feasible to know, without simply trying it. Yes, it's best to put the capacitors as close as possible. If 5cm is the closest you can get, than that's "as close as possible". Certainly adding the capacitors won't make anything worse.

We especially can't know if this will fix your problem because we don't know what your problem is. See Why does connecting a high-current device to my digital circuit cause weird behavior?