Michail Antonio also came close on 20 minutes as he let rip with a low shot from just outside the box, which the opposition stopper fumbled but gathered at the second attempt.
The deadlock was broken four minutes later through Hernandez, who was playing in his first club game of the campaign given his World Cup exploits with Mexico and subsequent break.
The Hammers had little issue holding on to their lead and Antonio should have doubled West Ham's advantage early in the second period but the 28-year-old blazed over from six yards out.
West Ham get their Premier League campaign underway on August 12 with a trip to Champions League finalists Liverpool.
WEST HAM UNITED: Fabianski, Fredericks, Ogbonna, Balbuena (Diop 46'), Cresswell (Masuaku 58'), Noble, Wilshere (Rice 77'), Antonio (Snodgrass 58'), Anderson (Obiang 58'), Arnautovic, Hernandez (Martinez 58')