A search is performed for long-lived massive neutral particles decaying to quark-antiquark pairs. The experimental signature is a distinctive topology of a pair of jets, originating at a secondary vertex. Events were collected with the CMS detector at the CERN LHC in proton-proton collisions at a center-of-mass energy of 8 TeV. The data analyzed correspond to an integrated luminosity of 18.5 fb(-1). No significant excess is observed above standard model expectations. Upper limits at 95 confidence level are set on the production cross section of a heavy neutral scalar particle, H, in the mass range of 200 to 1000 GeV, decaying promptly into a pair of long-lived neutral X particles in the mass range of 50 to 350 GeV, each in turn decaying into a quark-antiquark pair. For X with mean proper decay lengths of 0.4 to 200 cm, the upper limits are typically 0.5-200 fb. The results are also interpreted in the context of an R-parity-violating supersymmetric model with long-lived neutralinos decaying into a quark-antiquark pair and a muon. For pair production of squarks that promptly decay to neutralinos with mean proper decay lengths of 2-40 cm, the upper limits on the cross section are typically 0.5-3 fb. The above limits are the most stringent on these channels to date.