This is an interesting piece on gun ownership in Japan from a practitioner's view. While handguns are prohibited in Japan, acquiring hunting rifles and shotguns is possible, although the procedure is quite tricky and lengthy. There is a severe shortage of hunters to control wildlife.
Japan doesn't allow individuals to own firearms for other than hunting or target shooting, and there are no "sleeping guns," Neuville said, meaning that police will confiscate a gun if the owner doesn't use it for several years.
one-day class in firearm handling and safety followed by a test
psychological evaluation and background check that goes back 10 years
shooting trial at a trap range
gun and ammunition lockers, which must be anchored to walls in separate rooms; will be checked by the police.
A gun license in Japan expires after three years on the holder's birthday; renewal begins prior to the expiration date with an advance course in shooting. "For hunting, there is a one-day class you have to attend in person through the Yamaguchi Forestry Office that is held once a year in November," Neuville said. "And Japan really needs hunters."
Gun ownership is tightly controlled in Japan, but it’s possible for hunters and target shooters with the U.S. military to own a firearm after a lengthy, expensive process.
Americans can also get guns in Japan for those purposes. Some people I know locally were stationed in Iwakuni and got guns and hunted wild boar and such. They actually still go back and started a youtube channel about it https://www.youtube.com/c/BokenAdventure/videos Eric is half Japanese one 12 year cycle older than me (60s) and won the crossfit championship in his town a few years back. Eric has known Ma-chan and hunted with him in Japan for probably 30 years at this point. We shared the same Japanese tutor session after he came back for a while. Anyway my point is you as a foreigner can also get guns and hunt in Japan. Yes they do check the gun lockers they are serious about that. He also got arm bands for boar hunting and such as I recall, and as you imply farmers need it to protect their crops.
The article was written by someone stationed in Iwakuni specifically for service members there. I assume most regulations listed are national and apply to both nationals and foreign residents.