For 30 years China has recycled more cardboard boxes, plastic bottles and old computers than any other nation. By doing so, it saved millions of tons of resources and indirectly funded thousands of recycling programs and companies globally. But now it wants to stop. In July, China notified the World Trade Organization that it will soon prohibit the import of many types of recyclables. As a result, recycling programs and companies around the world are scrambling to find new destinations for the junk they once sent to China. In an increasing number of cases, that destination is a landfill.

It’s a true recycling crisis, but it doesn’t have to remain one. China’s decision — publicly the government claims the ban is driven by environmental issues associated with imported recycling — effectively deprives its companies of a cheap source of raw materials. That’s incentive for other countries, companies and programs to invest in new, cleaner technology to take China’s place and gain access to those materials for themselves. Archrival Japan, long a major global recycling exporter, may be the first to seize the opportunity.

Like so many other countries, Japan has for decades relied on China as a major destination for its recycling. This solved an immediate problem but was also a boon to Chinese manufacturers. After all, while environmental concerns have driven the expansion of recycling programs throughout the developed world, what goes into the blue bin is also manufacturing feedstock. In the United States, for example, almost 40 percent of the aluminum supply comes from recycled resources. Close to half of China’s copper supply is recycling-based.

This is especially true for difficult-to-recycle items such as electronic waste. “Mining” an old mobile phone for gold or other rare metals is far cheaper than digging a mine, particularly if labor is inexpensive and environmental controls are limited. China’s output was extraordinary: At its peak, the country’s leading e-waste processing zone produced 20 tons of gold from old electronics annually. That’s roughly equal to 10 percent of U.S. mined gold production in 2016.

The Chinese government has good reasons to get out of the trade. Pollution associated with electronic waste has become an embarrassing global concern; growing volumes of gadgets discarded by Chinese themselves have reduced the need to import more from abroad. Authorities had been steadily raising barriers to such goods before finally deciding to ban them altogether.

This leaves the market open. With long-term government support for research, some of Japan’s biggest companies are moving to deploy technologies at home and abroad that will replace some of the low-cost and polluting recycling systems long used in China.

For example, Mitsubishi Materials is investing over $100 million in precious metals refining plants devoted to electronics and — looking to the future — lithium-ion car batteries. Initially, Mitsubishi Materials will focus on Japan, but it’s also planning to open a plant in the Netherlands, where it will be in a position to manage at least some of the European Union’s electronic waste once bound for China. Crucially, those plants won’t only make money as service providers; Mitsubishi Materials also sees them as a hedge against expected future scarcity.

Of course, research and investment on that scale isn’t cheap or short term. Mitsubishi Materials, for one, doesn’t expect to have its recently announced plants fully operational until 2021. But once it does, the raw materials derived from those plants will be freely traded worldwide. Chinese manufacturers, now forced to import those materials, will face higher costs and lower competitiveness, while Mitsubishi Materials and Japan enjoy broad economic and environmental benefits. Indeed, the outlook is so bright that organizers of the 2020 Olympics are arranging for gold, silver and bronze medals for the games to be made from electronic waste generated by Japanese consumers.

It’s an investment lesson that recyclers and governments around the world should heed. In the U.S., the Trump administration could start by reversing its decision to defund Department of Energy programs focused on recycling technologies. Recycling already supports over 750,000 American jobs; investment focused on creating new sources of sustainable raw materials will create more.

At the same time, the private sector should work more closely with recyclers to develop clean technologies and methods that will keep recycling closer to home. Private programs like the U.S.-based Closed Loop Fund facilitate investment in such technologies for private companies and local governments, and they deserve broader corporate support. While no one program will suffice to make up for the loss of China’s recycling capacity, not investing at all would be a true waste.

Adam Minter is a Bloomberg View columnist. He is the author of “Junkyard Planet: Travels in the Billion-Dollar Trash Trade.”