If you have NetBeans installed, then the solution looks like:
Input
To be able to input the integers from the keyboard in Java, you can use the Scanner.
You need:
Once you have the two integers internally you can work with them as follows:
The algorithm for computing the gcd is clear. It is the normal Euclidean algorithm which switches x and y and makes y x % y at each step.
Try doing a dry run for this!
The output is shown above as well.
You can also create a Notepad++ file and run the code in IDEONE.com as follows: