Detective Daniel Pagnotta, the lead investigator in that case, said the gang leader had such a reputation for violence, and the options available to relocate the witness were so limited, that it was simply too risky. The police instead set up a sting operation that led to the arrest of the gang leader on narcotics charges.

They have not charged him in connection with the killing.

“We knew we could have gotten evidence to link him to the murder,” said Detective Pagnotta, who retired in June. “But it was pretty obvious that if we did, our witness would end up dead. So we took what we could get.”

Under the best of circumstances, the effort to spare civilians the ordeal of appearing in court can push the authorities to strengthen their cases by finding sturdier evidence.

When the Trenton police investigated a gang shooting outside the Jet Wine and Liquor Store in May 2005, detectives found a witness who was willing to help them, but he was extremely uneasy. Rather than put his name on a report that could be turned over to the suspect’s lawyers, or pushing him to testify before a grand jury, detectives looked for other options and struck gold: a videotape that showed the suspect with a gun. It led to an indictment for murder without the need for the witness to testify.

“They can’t intimidate a videotape,” Detective Pagnotta said.

Vernon J. Geberth, whose textbook “Practical Homicide Investigation” is used to train detectives in hundreds of police departments, cautioned that whatever forensic evidence or police testimony prosecutors may present at trial, there is no substitute for the power of a credible civilian witness.

“With witnesses, I always say the more the merrier,” said Mr. Geberth, who retired from the New York Police Department after serving as commander of the Bronx Homicide Task Force.

In Camden, attempts to build trust with residents has had mixed results. In 2004, when the police were making arrests in just 14 percent of all shootings, they formed a special response team to flood crime scenes with investigators and to canvass for witnesses. Today, the police solve more than 40 percent of all shootings, according to city statistics.