Find vector field given curl I have an equation $\nabla \times \vec{B} = \mu_{0}\vec{J}$, where $\vec{J} = \left\langle f(x,y), g(x,y), 0 \right\rangle$ and need to solve for $\vec{B}$. 
I've looked elsewhere on here for how to "undo" the curl operator, but every answer I've found has been very theoretical and abstract, and I was hoping to get a more concrete explanation for this particular problem. 
Breaking down the curl of $\vec{B}$ into components and partial derivatives, I got:
$$\frac{\partial B_{2}}{\partial x} - \frac{\partial B_{1}}{\partial y} = 0$$$$\frac{\partial B_{3}}{\partial y} - \frac{\partial B_{2}}{\partial z} = \mu_{0} f(x, y)$$$$\frac{\partial B_{1}}{\partial z} - \frac{\partial B_{3}}{\partial x} = \mu_{0} g(x, y)$$
And from here I'm stuck. Other examples with explicit functions have used guesswork to figure out the components, but I'm having trouble with the arbitrary functions of $f(x,y)$ and $g(x,y)$.
 A: It can't be solved in general. The divergence of the curl of a vector field is always zero; that means that 
$$
\frac{\partial}{\partial x} \mu_0 f(x, y) + 
\frac{\partial}{\partial y} \mu_0 g(x, y) = 0
$$
Even assuming that $\mu_0$ is a constant, that equality simply is not true for all functions. For instance, for $f(x, y) = x$ and $g(x, y) = 0$, it's false. 
A: 
As John Hughes already mentioned, we require $\nabla \cdot \vec J=0$.  Under that restriction, we proceed.


Since the curl of the gradient is zero ($\nabla \times \nabla \Phi=0$), then if 
$$\nabla \times \vec B =\mu_0 \vec J$$
for the magnetic field $\vec B$, then we also have 
$$\nabla \times (\vec B+\nabla \Phi) =\mu_0 \vec J$$
for any (smooth) scalar field $\Phi$. This means that there is not a unique solution to the problem since $\vec B +\nabla \Phi$ is also a solution for any (smooth) $\Phi$.
However, if we also specify the divergence of the magnetic field (we know that it is zero), then we can pursue a unique solution.  For example,
$$\nabla \times \nabla \times \vec B =-\mu_0 \nabla \times \vec J$$
whereupon using the vector identity $\nabla \times \nabla \times \vec B= \nabla ( \nabla \cdot \vec B)-\nabla^2 \vec B$ and exploiting $\nabla \cdot \vec B=0$ gives 
$$\nabla^2 \vec B=-\mu_0 \nabla \times \vec J$$
which has solution 
$$\vec B(\vec r)=\mu_0 \int_V \frac{\nabla' \times \vec J(\vec r')}{4\pi |\vec r-\vec r'|}dV'$$
where the volume integral extends over all space where $\vec J=\ne 0$.  We can integrate by parts in three dimensions by using the vector product rule identity $\nabla \times (\Phi \vec A) = \Phi \nabla \times \vec A+\nabla \Phi \times \vec A$ to write 
$$\begin{align}
\vec B(\vec r)&=\mu_0 \int_V \frac{\nabla' \times \vec J(\vec r')}{4\pi |\vec r-\vec r'|}dV'\\\\
&=\mu_0 \int_V \left(\nabla' \times \left(\frac{\vec J(\vec r')}{4\pi |\vec r-\vec r'|}\right) -\nabla' \left(\frac{1}{4\pi |\vec r-\vec r'|}\right) \times \vec J(\vec r') \right)dV'\\\\
&=\mu_0 \oint_S \frac{\hat n' \times \vec J(\vec r')}{4\pi |\vec r-\vec r'|}dS'-
\mu_0 \int_V  \nabla' \left(\frac{1}{4\pi |\vec r-\vec r'|}\right) \times \vec J(\vec r') dV'
\end{align}$$
Now, we may extend the integration region to all of space.  Then, if $\vec J=0$ outside a finite region, then the surface integral vanishes and we have
$$\begin{align}
\vec B(\vec r)&= -\mu_0
\int_V  \nabla' \left(\frac{1}{4\pi |\vec r-\vec r'|}\right) \times \vec J(\vec r') dV'\\\\
&=\mu_0 \int_V \nabla \left(\frac{1}{4\pi |\vec r-\vec r'|}\right) \times \vec J(\vec r') dV'\\\\
&=\nabla \times \left( \mu_0 \int_V \frac{\vec J(\vec r')}{4\pi |\vec r-\vec r'|}dV' \right)
\end{align}$$
where the first equality is effectively the Biot-Savart law and the last equality reveals that $\vec B =\nabla \times \vec A$ for the vector potential 
$$\vec A(\vec r) = \mu_0 \int_V \frac{\vec J(\vec r')}{4\pi |\vec r-\vec r'|}dV'$$
