For a ring map $f:A\to B$, closure of image of $V(J)$ under associated map on Spec is $V(f^{-1}(J))$

Let $f:A \to B$ be a (commutative unitary) ring homomorphism. Let $X:=\operatorname{Spec} A$ and $Y:=\operatorname{Spec} B$, and call $f^*$ the induced function $Y\to X$. Show that, for any ideal $J\subseteq B$, one has $$\overline{f^*(V(J))}=V(f^{-1}(J)).$$

Now, it's clear that $V(f^{-1}(J))$ is a closed set containing $f^*(V(J))$: in fact suppose that a prime $p\in X$ is equal to $f^{-1} (q)$ for some $q\in V(J)$. Since $J\subseteq q$, also $f^{-1}(J)\subseteq p$. This proves that $\overline{f^*(V(J))}\subseteq V(f^{-1}(J))$.

For the other inclusion, I thought to take a closed set $V(I)$, for an ideal $I\subseteq A$, such that $f^*(V(J))\subseteq V(I)$, and prove that $V(f^{-1}(J))\subseteq V(I)$. However I don't see how to proceed here, do you have any hint?


Take a point $x\in X$ which is not in the closure of $f^*(V(J))$. This means that we can find some $a\in A$ which vanishes on $f^*(V(J))$ but not on $x$. Saying $a$ vanishes on $f^*(V(J))$ means $a\in f^{-1}(J)$, though, so this shows that $x\notin V(f^{-1}(J))$.