John Shaw developed an early interest in natural history and in 1856, when he was 19, the distinguished German expert on mosses, W.P. Schimper, Professor of Geology and Director of the Natural History Museum in Strasburg, accompanied him on a tour in Scotland to collect mosses. During the next few years Shaw trained as a teacher at the Free Church Training College (later Jordanhill College of Education) in Glasgow. He then taught at the college until 1867. During these year he served on the council of the Natural History Society of Glasgow and continued his studies of mosses, publishing two papers on British mosses in the Journal of Botany (London) in 1865 and 1866. He also studied geology at the University of Glasgow (with D.D. Fraser*) and was awarded a gold medal for his achievements. Later he qualified as Doctor of Philosophy (PhD). In 1873 he was elected a Fellow of the Linnean society and in December that same year as a Fellow of the Geological Society of London.
Shaw emigrated to the Cape Colony to become headmaster of the Colesberg Collegiate School, arriving in October 1867. His scientific reputation must have preceded him, for on 9 October 1867 he was elected an honorary member of the Albany Natural History Society. Two years later he undertook a study of the geology of the recently discovered diamond deposits along the Vaal River near present Kimberley. His observations were published in a series of articles entitled "The geology of the diamondiferous tracts of South Africa". The first of these appeared in the South African Magazine (1869, Vol. 3, pp. 785-787), the rest in the Cape Monthly Magazine (Series 2, 1870, Vol. 1, pp. 129-133, 249-253, 368-372; 1871, Vol. 2, pp. 358-364). He described the various rock strata found in the region and concluded that the presence of garnet and peridote in gravel indicated the presence of diamonds, as these were the only two unusual minerals found in both the river diggings and the so-called dry diggings. In later notes in the Cape Monthley Magazine (Series 2, 1874, Vol. 9, pp. 40-50, 254-256) he strongly criticised E.J. Dunn's* geological sketch map of the Northern Cape, but some of his criticisms reflect shortcomings in his own knowledge or observations. For example, he denied the presence of dolerite dykes where Dunn had indicated them, quibbling about the name of the rock, and objected against Dunn's conclusion that the conglomerates now known as the Dwyka tillite were the result of glacial action. The debate between the two continued in the pages of the magazine for two years.
Meanwhile Shaw also continued his study of mosses and other plants. In 1869 he contributed an essay on "The natural history of a moss" to The Cape and its peoples, a volume edited by Professor Roderick Noble*. A few years later he presented a "Catalogue of the mosses of the Cape Colony... with short descriptions of new species" in the Cape Monthly Magazine (1878, Vol. 17, pp. 311-320, 376-383). The information was based on a study of his own collection and those of P. MacOwan*, H. Bolus* and J.H. McLea*. Even though it had been compiled after considerable work in the herbarium at Kew Gardens, London, it included many species of which the South African identifications are doubtful (Sim, 1926). Shaw also collected lichens near the diamond fields, which were described by James Stirton in the Transactions of the Glasgow Society of Field Naturalists in 1877. During a visit to England in 1873 he read a paper at the annual meeting of the British Association for the Advancement of Science entitled "On the changes going on in the vegetation of South Africa through the introduction of merino sheep". This paper, which was published in the Journal of the Linnean Society (Botany) (1874) as well as in the Veterinarian (1874), was one of the first scientific papers dealing with pasture ecology in southern Africa. In it he argued that overstocking the land with sheep was hastening the drying up of the country. The plant species Albuca shawii was named after him. Flowering plants collected by him are in the herbarium at Kew Gardens.
In April 1874 Shaw was appointed head of the South African College School in Cape Town, an institution that had just been separated from the rest of the South African College to deal with pre-matriculation classes. Shaw and the Senate of the College held conflicting views with regard to courses of study and suitable textbooks, as the Senate favoured an education that would prepare students for the College's educational programmes, whereas Shaw was more concerned with a general school course. Despite such friction the school grew in terms of student numbers, educational standards and reputation. Furthermore, in January 1876 Shaw was appointed by the College Council to the additional post of professor of physical science at the College, while at the same time P.D. Hahn* was appointed Jamieson professor of experimental physics and practical chemistry. There were insufficient students at the time to warrant both appointments, with the result that Shaw had no students and was a professor in name only until his post was abolished in 1878. His textbook, The geography of South Africa. Physical and political was published in 1878. He remained head of the South African College School until his death in 1890.
Shaw became a foundation member of the South African Philosophical Society in 1877 and served on its council during the first two years. At the first ordinary meeting of the society, on 26 September 1877, he read two papers. The first of these, "Remarks on Rodidula dentata, one of the insectivorous plants", dealt with the peculiar plant commonly known as the Fly-catcher bush. The other, "On the age of the volcanic throats of the Upper Karroo Formations of South Africa", contained Shaw's observations of kimberlite pipes (without diamonds) in the Karoo. He was able to conclude that they were much younger than the volcanic events that ended the deposition of the Karoo strata and were probably of Teriary age. Both papers were published in the society's Transactions (1877, Vol. 1, pp. 1-6 and 11-12). In a later paper he discussed "The petrography of Table Mountain valley" (Transactions, 1879, Vol. 1(2), pp. 55-65). In October 1881 he exhibited a new fossil reptile from the Karoo shales of Griqualand West. Years later he contributed a note "On fossil plants from Indwe and Cyphergat Coal Beds" (Transactions, 1884-1888, Vol. 4(1), pp. 44-45).
In January 1888 Shaw presented a lecture on "South African minerals" at the Queen's Jubilee South African Exhibition in Grahamstown. In this lecture he proposed the formation of a local geological society. The proposal was acted upon in June that year when the South African Geological Association was founded in Grahamstown with W.G. Atherstone* as president. Shaw was elected a member of its committee for the first year. He was also active in educational matters during the last years of his life, among others as editor and proprietor of the Educational Times. In 1888 he was elected on the committee of the South African Teachers' Association, served as joint vice-chairman at its Conference in 1889, and was president-elect at the time of his death in June 1890.