It's no problem to wear shorts in cities. (Many people wear shorts in summer... summer in Tokyo is so hot!) Though, we don't allow wearing shorts or sandals in business scenes usually.
If you are going to nice restaurants or traditional places, it's safer to cover your legs.
It's usually no problem unless you go to a nice expensive restaurant:)