We have $x^y = y^x$, with $0 < x < y$ (WLOG).
Let $y= rx$, where $r > 1$.
Then $x^{rx} = (rx)^x$.
Taking the natural logarithm of both sides, $rx \ln x = x (\ln r + \ln x)$.
Dividing by $x$, and rearranging, $(r−1) \ln x = \ln r.$
(Notice that $r = 1$ would be a solution, from which $y = x$.)
With $r > 1$, $\ln x = (\ln r) / (r−1).$
Taking exponentials,$ x = e^{(\ln r) / (r−1)} = (e^{\ln r})^{1/(r−1)}$.
Therefore we have the parametric solution, $x = r^{1/(r−1)}, y = rx = r^{r/(r−1)}.$
If we set $r = 1 + 1/k$, where $k > 0$, we have $x = (1 + 1/k)^k$, $y = (1 + 1/k)^{k+1}$.
Since $r > 1, 1/(r−1) $is positive, and so $x > 1$, and therefore $y > 1$.
(Notice that, if we allow $0 < r < 1, 1/(r−1) $and $r/(r−1)$ are negative, and so again $x$ and $y$ are greater than $1$. Of course, this must be the case, because $r = a$ and $r = 1/a$ yield essentially the same solution, with $x$ and $y$ swapped.)
We have shown that, for a rational solution, $k$ is an integer; that is $x = [(a + 1)/a]^a$.
If $a > 1$, $a$ and $a + 1$ are relatively prime, and so $[(a + 1)/a]^a$ is a fraction in its lowest terms, with denominator $> 1$, and therefore not an integer.
So the only integer solution is $x = 2, y = 4$.
Hope this helps. Correct me if I'm wrong!
You can refer here for more discussion on the same problem!