Do you need to do it in Python or Java? I do a lot of programming in Python, but this can be done much more concisely with integer program using a language like AMPL or GLPK, which I find more elegant (and generally more efficient) for problems like this.
Here it is in AMPL, although I haven't verified how this works:
http://taha.ineg.uark.edu/Sudoku.txt