 He graduated from the Schottengymnasium in Vienna and studied medicine at the University of Vienna, receiving his medical doctorate in 1876.He then learned chemistry and physiology under Max von Pettenkofer (1818–1901) and Karl von Voit (1831–1908) in Munich and Karl Ludwig (1816–1895) in Leipzig.Also working under Pettenkofer was Hans Ernst August Buchner (1850–1902), who encouraged Gruber to concentrate on bacteriology.