In order to investigate the formation of relativistic jets at the center of a progenitor of a gamma-ray burst (GRB), we develop a two-dimensional general relativistic magnetohydrodynamic code. We show that the code passes many well-known test calculations, and confirm the reliability of the code. Then we perform a numerical simulation of a collapsar using a realistic progenitor model. It is shown that a jet is launched from the center of the progenitor. The structure of the jet is similar to the previous study: a Poynting flux jet is surrounded by the funnel-wall jet. Even at the final stage of the simulation, the bulk Lorentz factor of the jet is still low, and the total energy of the jet is still as small as 1048 erg. However, we find that the energy flux per unit rest-mass flux is as high as 102 at the bottom of the jet. Thus, we conclude that the bulk Lorentz factor of the jet can be potentially high when it propagates outward. Also, as long as the duration of the activity of the central engine is long enough, the total energy of the jet can be large enough to explain the typical explosion energy of a GRB (~1051 erg). It is shown that the outgoing Poynting flux exists at the horizon around the polar region, which proves that the Blandford-Znajek mechanism is really working. However, we conclude that the jet is mainly launched by the magnetic field amplified by the gravitational collapse and differential rotation around the black hole, rather than the Blandford-Znajek mechanism.