A Hempstead man will serve 18 years in prison for trying to murder a former friend whom he blamed for a previous incarceration, Nassau prosecutors said Tuesday.

James Jacobs, 31, fired at least three times at the victim and his mother — who were in a car — with a .40 caliber semi-automatic pistol on Oct. 4, 2015, prosecutors said in a statement.

He had chased the two people in his car after spotting them while driving on Hempstead’s Long Beach Road, District Attorney Madeline Singas said in a statement.

The victims, who escaped injury, called the police; Jacobs was arrested that day, she said.

After about a two-week bench trial, Jacobs was convicted of three felonies — attempted murder, criminal possession of a weapon and reckless endangerment — on June 12, 2017, Singas said.

Richard Langone, a Garden City attorney who replaced the defendant’s lawyer after the trial, said the conviction will be appealed.

“No one at the trial identified him as the shooter and we believe the circumstantial evidence is legally insufficient, but that is a matter that will have to be decided on appeal,” he said by telephone.

Langone said the judge had asked him to represent the defendant because he was “unhappy with his prior counsel.”

Get the Breaking News newsletter!

The defendant and the victim were friends for many years until 2010, when Jacobs went to prison “for an unrelated incident, which the victim was a part of,” Singas said.

After Jacobs was released, he began to threaten his former friend, she said.

Singas saluted Nassau and Hempstead police for their quick work.

“James Jacobs carried out a vendetta against his former friend and jeopardized the lives of everyone around him when he fired his weapon into a car — on a public street — in the middle of the afternoon,” she said.