The MLB All-Stars scored two runs in the fourth inning and Longoria made it 6-0 with a blast over the centerfield wall in the fifth inning at Koshien Stadium.
"I was able to get a good pitch and drive it," Longoria said. "We don't know a lot about these guys so you've got to try to come into the game and put the bat on the ball."
Salvador Perez hit a solo homer in the sixth, and Hiroki Uemoto drove in a run in the bottom of the sixth, but the All-Stars responded when Dexter Fowler hit a solo shot in the seventh to make it 8-1.
But the hosts rallied, scoring five runs in the seventh, and another in the eighth to make it a one-run game.
All-Stars manager John Farrell said he was pleased with the result.
"Tonight was more than we could have asked for," Farrell said. "We were able to get every position player on the field, we were able to go to our bullpen, but their competitiveness forced us to make some plays."
Chris Capuano picked up the win after striking out three and holding Japan to one hit over four scoreless innings.
The five-game series against Japan will start on Wednesday at Kyocera Dome in Osaka. There are also games at Tokyo Dome, Sapporo Dome and Cellular Stadium in Okinawa.
The series marks the first time since 2006 that a MLB All-Star team has visited Japan. The Japan team was made up of members of the country's two most popular professional teams, the Yomiuri Giants and Hanshin Tigers.