Like most Castilian textile centres, Segovia joined the Revolt of the Comuneros under the command of Juan Bravo. Despite the defeat of the Communities, the city's resultant economic boom continued into the sixteenth century, its population rising to 27,000 in 1594. Then, as well as almost all the cities of Castile, Segovia entered a period of decline. Only a century later in 1694, the population had been reduced to only 8,000 inhabitants. In the early eighteenth century, Segovia attempted to revitalize its textile industry, with little success. In the second half of the century, Charles III made another attempt to revive the region's commerce; it took the form of the Royal Segovian Wool Manufacturing Company (1763). However, the lack of competitiveness of production caused the crown withdraw its sponsorship in 1779. In 1764, the Royal School of Artillery, the first military academy in Spain, was opened. This academy remains present in the city today. In 1808, Segovia was sacked by French troops during the War of Independence. During the First Carlist War, troops under the command of Don Carlos unsuccessfully attacked the city. During the nineteenth and first half of the twentieth century, Segovia experienced a demographic recovery that was the result of relative economic stability.