The equation in your question, be it Heisenberg or Ising exchange, can be calculated by Energy mapping analysis. This has to be the most popular paper that discusses this technique. Basically, you consider different spin configurations and map the exchange 'J' into the total energy values from DFT.
In the simplest form, if you have two magnetic atoms in your unit cell, there are four possible spin configurations - $\uparrow$$\uparrow$ , $\uparrow$$\downarrow$, $\downarrow$$\uparrow$,$\downarrow$$\downarrow$, denoted by $E_1, E_2, E_3, E_4$ respectively. The exchange 'J' can be estimated as $1/4* (E_1 - E_2 - E_3 + E_4$). Now, the energy values for the four different configurations are just the total energy values from your DFT calculation. Typically, you would need to constrain your magnetization on the magnetic atoms in your DFT package. If you want to include anisotropic exchange, you need to consider spin-orbit coupling as well.