A school resource officer said the .32 automatic handgun was found in the pocket of the student's hoodie.
A magazine loaded with 8 rounds was found in the boy's pants pocket.
Officials said protocol at the alternative school requires all students be searched prior to reporting to their assigned classrooms.
"He had told the teachers that he had initially gone hunting over the weekend with some friends, and that he forgot to put the gun back up," said Debbie Tanna, with the Cumberland County Sheriff's Office. "It's just surprising how you wouldn't notice it when you put the hoodie on. It's very heavy."
The teen was taken to the Cumberland Regional Juvenile Detention Center. He's facing a felony charge of bringing a weapon onto a school campus.
Because the student was caught before entering the school, the campus was never put on lockdown and students went on to class as normal.