'High School Musical 3' Star Detention Won't Cut It ... Gets 18 Months Behind Bars

5/31/2016 12:48 PM PDT

'High School Musical 3' Star: Detention Won't Cut It ... Gets 18 Months Behind Bars

EXCLUSIVE

Justin Martin -- who co-starred with Zac Efron in 'High School Musical 3' -- will be locked up for 18 months after pleading guilty to 5 gun charges ... TMZ has learned.

The Suffolk County D.A.'s office tells us Martin appeared in court Tuesday for sentencing. In addition to the jail time ... he also got one year probation, during which he has to lay off drugs and booze and stay away from the scene of the crime.

As we reported back in July ... Martin ran away from cops in Boston and pointed a gun at officers before he was chased and captured. He pled guilty to assault with a dangerous weapon, illegal possession of a gun and ammunition, carrying a loaded gun and firing a gun near a building.

Justin tells TMZ, "I have matured a great deal in the past year and had to learn some hard lessons because of my actions."  He added, "I look forward to moving past this time in my life and getting back to my career."

Martin avoided a stiffer penalty -- the D.A. was gunning to lock him up for 3 years.