There is no law that defines Japanese as the official language of Japan.
The USA is known to have no official language at the federal level because of the diversity of people who originally came from many other countries, while the State of California defines English and Spanish as the official languages of the state.
Japan, on the other hand, has no law, constitute, etc. explicitly stating that the official language of Japan is Japanese. Perhaps the reason for this is because the population of Japan has been mostly Japanese people and the Japanese language has been the only language spoken in the country; therefore, there has been no particular need to define Japanese as the official language. Japanese people never think of it but for this reason Japanese is not the official language of Japan.
That said, the Court Act (the law concerning courts) states in Clause 74 that the language used in court must be Japanese.
While Japanese is the de facto official language of Japan, there could be a minor problem if Japanese society attempted to designate an official language because there are so many dialects in the county. The differences in dialects in Japan are not limited to pronunciation differences. Such differences among dialects could be considered totally different languages if they were spoken elsewhere in the world. However, due to the spread of TV and other mass media in the last century, so-called standard Japanese* can be understood by almost everyone; therefore, so-called standard Japanese would have a chance of becoming the official language.
*There is an interesting perspective with regards to standard Japanese. Standard Japanese is a language commonly spoken on TV and the radio. Many Japanese people, especially those from Tokyo, believe that the Japanese which people in Tokyo speak is standard Japanese, but it is not. It is the Tokyo dialect. Even within Tokyo, people in different areas have different accents (at least to the ears of linguists).
Also, nowadays there are those who believe that English should become the official language. Many people think that Japanese people should learn English so that they can better communicate with people from outside Japan and because the number of people travelling or moving to Japan from other parts of the world is increasing. There is much room for discussion because there is no official language in Japan.