I know some of them travelled to Europe to borrow ideas from European countries. But what about the rest of them?
The Samurai class was about 5% of the total population of about thirty million. So, there were a lot of Samurai who just lost a job. The following is from a paper I wrote on the subject:
Samurai were so highly valued in feudal Japan thanks to their lifetime of training in the art of war, their monopoly on the tools of war, and the use of these two values as officers of the peace. Without these valuable traits and possessions, society could no longer justify their existence. The samurai Abei Iwane in 1874 wrote about this transformative time and the difficulties he and his fellow samurai faced.(Samurai Dissestablished) For hundreds of years, samurai roamed the land instilling justice and educating the populace during peacetime under the patronage of their daimyo. The daimyo paid the samurai regular stipends paid out of the daimyo's tax revenues. The task of formally and legally abolishing the feudal class system was easy; removing the informal social superiority of the samurai and integrating them into the rest of society as equals was not.
The central government took gradual steps in the reintegration of the samurai. In 1869, the daimyo were given only one-tenth of their former income. The central government gave the order to 'reform.' This is to say, they would be forced to reduce the stipends paid out to the samurai to push them out into other occupations. In 1871, the samurai were ordered to lay aside their swords. With this, the samurai were no longer allowed to wear in public their katana (Samurai disestablished 298-300), and so were no longer allowed the honor presenting for others their inherited pride from generations of warrior ancestors. Also in 1871, the domains ruled by the daimyo that the samurai so faithfully followed were officially abolished. They were replaced with prefectures ruled by elected governors who were often successful businessmen. Could the government expect them to follow a businessman, an occupation traditionally shunned upon for their deal making and profit motives by Confucian ethics? (Daimyo 45)
Although some samurai like Abei Iwane wrote of proudly sacrificing his status and stipend for the sake of national social unity, life for the samurai in this period was difficult. Since childhood they were taught that they were above the commoners. Their honorable bushido duty was to learn and study the arts of war and the mastery of their katana. What kind of life could they live now? Historian Brian Platt, Department Chair at George Mason University, claimed that many of the samurai, being the most educated class, became teachers and joined the Shinto and Buddhist priests in the rapidly expanding education system. (Childhood 966-968) Others turned to vagrancy. The final straw for the samurai's stipend came in 1876, when instead of an annual stipend, samurai were given five to seven and a half years of stipend income in the form of interest bearing bonds. The intent of the bonds was that when they came to maturity, the samurai would be in position to buy plots of government land at a discounted price or begin their own business. (Samurai Disestablished 301) But most samurai were still stuck in their traditional ways in a rapidly changing Japan. One government inspector wrote about the samurai in an official report on the subject: "The [samurai in Ishikawa] are lazy and inactive, and still have not shed their old habits. Although they have been loaned funds to establish enterprises, only a few have achieved their goals. Most of them do not work and thus produce nothing. As the days go by, they increasingly face hunger and cold, but they do not display the spirit to help themselves and just depend on others for their living. (Samurai Disestablished p. 305-306) The social structures in Japan had come full circle: the samurai went from social superiors, to battlefield equals, to economic dependents.
The samurai could not live as vagrants for ever. Eventually, they came to accept their new station in life and integrated with the rest of society. They became artisans, merchants, and farmers. Many joined the national army as officers or became civil servants. "As a trite Japanese saying goes, 'What the upper likes, the lower learns to like still more.'" (Ind Rev 678) Prime Minister Shigenobu was referring to the top-down spread of culture in the pre-Meiji era. When business leaders dressed in suits instead of robes armed with pens instead of swords rose to the top of the Japanese social hierarchy and changed the direction of Japanese cultre, the samurai acquiesced.
/u/blatherskiter provides a good overview of the policies intended to abolish the class distinction of samurai in relation to commoners. However there is another side to that coin which also deserves mention - the Meiji government's explicit attempt to rehabilitate the samurai class.
The Meiji government was keenly aware of the economic plight of the former samurai. By some estimates as many as 8 out of 10 former samurai were impoverished (though not all of this was a result the Meiji reform - a significant number of samurai were already impoverished by the end of the Tokugawa period). But former samurai were also seen as natural leaders, who could play a crucial role in leading the nation's modernization.
As a result throughout the 1870's and 1880's the government pursued a samurai rehabilitation program (shizoku jusan). This program was intended to find useful employment for ex-samurai, while at the same time benefiting the government's modernization activities.
Three major efforts of this rehabilitation were: encouraging former samurai emigration and reclamation of new areas; establishing branches of the national bank to safeguard former samurai investments; and providing capital support to former samurai engaging in agriculture, industry, and commerce.
The program was only partially successful. The plight of impoverished ex-samurai was never fully relieved for another generation, though it was improved to the point that samurai rebellions ceased. However the program played a key role in modernization through land reclamation (for example, Japanese settlement in Hokkaido greatly expanded in this period), and its agriculture, industry and financial development practices.
An excellent overview of the Meiji government's samurai rehabilitation program comes from Harry D. Harootunian "The Economic Rehabilitation of the Samurai in the Early Meiji Period." The Journal of Asian Studies 19 (1960): 433-444. (available on JSTOR).