The student fled but was caught and the gun was recovered.
Three 15-year-olds and one 14-year-old are each charged with aggravated unlawful use of a weapon.
Police say one of the teens had a second weapon which has not been recovered.
The teens are being held at the Lake County Juvenile Detention Center in Vernon Hills.