Hadron masses can be decomposed as a sum of quark and glue components that are defined through hadronic matrix elements of QCD operators. The components consist of the quark mass term, the quark energy term, the glue energy term, and the trace anomaly term. We calculate these components for mesons with lattice QCD for the first time. The calculation is carried out with overlap fermion on 2 + 1 flavor domain-wall fermion gauge configurations. We confirm that similar to 50% of the light pion mass comes from the quark mass term and similar to 10% comes from the quark energy; whereas, for the rho meson, the quark energy contributes roughly half of its mass but the quark mass term contributes little. The combined glue components contribute similar to 40-50% for both mesons. It is interesting to observe that the quark mass contribution to the mass of the vector meson is almost linear in quark mass over a large quark mass region below the charm quark mass. For heavy mesons, the quark mass term dominates the masses, while the contribution from the glue components is about 200 MeV (a bare value around 2 GeV) for the heavy pseudoscalar and vector mesons. The charmonium hyperfine splitting is found to be dominated by the quark energy term which is consistent with the picture of the quark potential model.