IT IS VALID BUT ANNOYING ENGLISH TO WRITE LIKE THIS
It's ugly (and the longer you do it, the uglier it gets) it loses any meaning conveyed by capitalisation, but when it comes to the writing of words, it's allowed.
Most of the time, it would be a bad idea. With more than a few words it so stymies legibility as to be downright rude to the reader.
It's most appropriate in cases like road signs, where the increased visibility is important, and the decreased legibility minor as the effect is lessened with short passages.
The case of book titles on covers is one where we use text both for the information conveyed through language, and as a graphical element in a picture. Hence choices like colour, size, typeface used, positioning relative to other graphical elements, and so on, all come up more pressingly than with most text. One of the options the graphical designer has, is to transform the text to all-caps (or all-miniscule, where "thinking in java" would be used, but this is a much rarer choice that for both linguistic and visual reasons is less often appropriate).
In such cases, you should think of the title as being "Thinking in Java", with the all-caps being a visual effect rather than an aspect of language.