Your code is a bit messy. If you'd just format your code (at least use indentation correctly) then you'd see the missing or extra braces.
I did this for you.
Apart from mismatch braces, you had two main classes.
I also applied the fix we talked about in http://question.onlinegdb.com/10412/why-getting-in-my-solution-for-chessboard-where-is-my-mistake.
And last, but not least, I made your code more like a proper Java code: using classes that can be instantiated and not just being a collection of static functions. Now you can just instantiate your Knight class with any size and see if you can find any results there.
public class Main
{
public static void main(String []args)
{
Knight knight = new Knight(8);
knight.solve();
}
}
class Knight
{
private static int xMove[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
private static int yMove[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
private int size;
private int result[][];
public Knight(int _size)
{
size = _size;
result = new int[size][size];
}
private boolean check(int x, int y)
{
return x >= 0 && x < size && y >= 0 && y < size && result[x][y] == -1;
}
private void printResult()
{
for (int x = 0; x < size; x++)
{
for (int y = 0; y < size; y++)
System.out.print(result[x][y] + "\t");
System.out.println();
}
}
public boolean solve()
{
for (int x = 0; x < size; x++)
for (int y = 0; y < size; y++)
result[x][y] = -1;
result[0][0] = 1;
if (!solve(0, 0, 2))
{
System.out.println("Knight Tour not found");
return false;
}
printResult();
return true;
}
private boolean solve(int x, int y, int moveCount)
{
if (moveCount == size * size + 1)
return true;
for (int k = 0; k < 8; k++)
{
int next_x = x + xMove[k];
int next_y = y + yMove[k];
if (check(next_x, next_y))
{
result[next_x][next_y] = moveCount;
if (solve(next_x, next_y, moveCount + 1))
return true;
result[next_x][next_y] = -1;
}
}
return false;
}
}