Abstract: A study of the production of J/psi mesons in association with jets in proton-proton collisions at CM energy of 8~TeV is presented. The analysis is based on data corresponding to an integrated luminosity of 19.1 inverse femtobarns collected with the CMS detector at the LHC. For events with at least one observed jet, the angular separation between the J/psi meson and the jet is used to test whether the meson is a jet fragment. The differential distributions of the jet fragmentation probability as a function of jet energy for a fixed J/psi energy fraction are presented. The experimental results are compared to a theoretical model using the fragmenting jet function (FJF) approach. The jet fragmentation data agree with the predictions of the FJF calculations that use specific long-distance matrix element parameters. This agreement shows that the combination of data on jet fragmentation to J/psi mesons and FJF analysis is a new way to test predictions for J/psi meson production from nonrelativistic quantum chromodynamics. The results indicate that the jet fragmentation mechanism produces unpolarized J/psi mesons. The analysis also shows that most J/psi mesons with energy above 15 GeV and rapidity |y|<1.0 are fragments of jets with pseudorapidity < 1.