How to calculate surface current density So I have the question where you have an infinitely long cylinder, with $\vec{B}(r)=\frac{B_{0} r}{R} \vec{e}_{\varphi}$. Then with $\oint \vec{B} \cdot \overrightarrow{d l}=\mu_{0} I_{e n c l}$, with $I_{encl} = \vec{J}(r) \pi r^2 $, the current density times the area. 
Then calculating $\vec{J}(r)$ is straightforward, as $\vec{J}(r) = \frac{2B_0}{\mu_0 R} \vec{e_z}$, so the current is flowing upward along the z-axis. Now outside the cylinder, $B=0$. It is told that this is due to a surface current, with current density $\vec{J_s} = -\frac{B}{\mu_0} \vec{e_z}$.  How do I calculate this however?
 A: Let me point out that your question or statement of the problem is incomplete or you seem to be doing things in reverse. I will try to answer as based on what I assume or guess you are trying to ask. So let me reconstruct what I think is the question.


*

*There is an infinite cylindrical conductor of radius $R$

*The magnetic field inside is given to be $\vec{B}(r)=\frac{B_{0} r}{R} \vec{e}_{\varphi}$

*The magnetic field outside is given to be zero. 
Now you need to find the current density.
There is a bit of technical inaccuracy in how you found the current density from the current. You wrote 

$$I_{encl} = \vec{J}(r) \pi r^2 $$

Its actually 
\begin{eqnarray}
I_{encl} = \int \vec{J}(r)\cdot da {\perp}
\end{eqnarray}
Lucky for you, In this case $\vec{J}(r)$ turned out to be a constant.
We know that 
$\oint \vec{B} \cdot \overrightarrow{d l}=\mu_{0} I_{e n c l}$
So if we consider a circular Amperian loop at a radius $r<R$. The current enclosed inside the circle $I(r)_{encl}$ can be found by
\begin{eqnarray}
\oint \frac{B_{0} r}{R} \vec{e}_{\varphi} \cdot |d l|\vec{e}_{\varphi}=\mu_{0} I(r)_{e n c l}\\
\frac{B_{0} r}{R}(2\pi r) = \mu_{0} I(r)_{e n c l}\\
\end{eqnarray}
$$I(r)_{e n c l} = \frac{2\pi B_{0} r^2}{\mu_{0}R} $$
Using the right we can deduce that to create a magnetic field along $\vec{e}_{\varphi}$ the current needs to be upwards or +ve z direction. The current density is then the current divided by the perpendicular area which is $\pi r^2$. Which gives you
$$\vec{J}(r) = \frac{2B_0}{\mu_0 R} \vec{e_z}$$
Which is a constant current density across $r$. The total volume current on the cylinder comes out to be
$$I_{v,encl} = \frac{2\pi R}{\mu_0 }B_0$$
Actually 
$$\vec{J}(r) = \frac{dI}{da_{\perp}}$$
But here simple division will give the answer. But be careful when its a non-uniform current density. In such cases you will have to and is safer to use the above equation.
Now we know that the field outside is zero. But the volume current we just found out produces a magnetic field outside which is equal to
$$\vec{B_{vol}} = \frac{\mu_0 I_{encl}}{2\pi r}\vec{e}_{\varphi}           $$
$$\vec{B_{vol}} = \frac{ R}{ r}B_0\vec{e}_{\varphi}$$
For $r>R$
For the field outside to be zero there should then be some surface current that exactly cancels this out.
$$I_{s,encl} = - \frac{1}{\mu_0} \int \frac{ R}{ r}B_0\vec{e}_{\varphi} \cdot \vec{dl}$$
$$I_{s,encl} = - \frac{1}{\mu_0}  \frac{ R}{ r}B_0\times 2\pi r$$
$$I_{s,encl} = -   \frac{ 2\pi R}{\mu_0 }B_0   $$
Then the surface current density $\vec{J_s}$ at $R$, directed in the negative z direction is is 
$$\vec{J_s} = \frac{I_{s,encl}}{2\pi R}\vec{e_z} = -\frac{B_0}{\mu_0}\vec{e_z}$$
