  Planetesimal accretion is a key source for heavy-element enrichment in giant
planets. It has been suggested that Jupiter's enriched envelope is a result of
planetesimal accretion during its growth assuming it formed in a massive
planetesimal disk. In this study, we simulate Jupiter's formation in this
scenario. We assume in-situ formation and perform N-body simulations to infer
the solid accretion rate. We find that tens-Earth masses of planetesimals can
be captured by proto-Jupiter during the rapid gas accretion phase. However, if
several embryos are formed near Jupiter's core, which is an expected outcome in
the case of a massive planetesimal disk, scattering from the embryos increases
the eccentricity and inclination of planetesimals and therefore significantly
reduces the accretion efficiency. We also compare our results with published
semi-analytical models and show that these models cannot reproduce the N-body
simulations especially when the planetesimal disk has a large eccentricity and
inclination. We show that when the dynamical evolution of planetesimals is
carefully modelled, the total mass of captured planetesimals
$M_\mathrm{cap,tot}$ is $2 M_\oplus \lesssim M_\mathrm{cap,tot}\lesssim 18
M_\oplus$. The metallicity of Jupiter's envelope can be explained by the
planetesimal accretion in our massive disk model despite the low accretion
efficiency coming from the high eccentricity and inclination of planetesimals.
Our study demonstrates the importance of detailed modelling of planetesimal
accretion during the planetary growth and its implications to the heavy-element
mass in gaseous planets.
