The remarks come amid the countries' worst diplomatic crisis in years, after Japanese Prime Minister Sanae Takaichi said this month a hypothetical Chinese attack on Taiwan could trigger a military response from Tokyo.
Japan's Defence Minister Shinjiro Koizumi said on Sunday that plans were "steadily moving forward" to deploy a medium-range surface-to-air missile unit at a military base on Yonaguni, an island about 110 km (68 miles) off Taiwan's east coast.
Asked about the deployment, which China's foreign ministry has already criticised, the country's defence ministry said how to "resolve the Taiwan question" was a Chinese matter and nothing to do with Japan, which controlled Taiwan from 1895 until the end of World War Two in 1945.
"Not only has Japan failed to deeply reflect on its grave crimes of aggression and colonial rule in Taiwan, it has instead, in defiance of world opinion, entertained the delusion of military intervention in the Taiwan Strait," spokesperson Jiang Bin told a regular news briefing.
"The People's Liberation Army has powerful capabilities and reliable means to defeat any invading enemy. If the Japanese side dares to cross the line even half a step and bring trouble upon itself, it will inevitably pay a painful price," he added.
Taiwan's democratically elected government rejects Beijing's territorial claims, saying only the island's people can decide their future.
Taiwan President Lai Ching-te this week unveiled plans to spend an extra $40 billion on defence over the coming eight years, which China criticised as a waste of money that would only plunge Taiwan into disaster.
Asked about that criticism, Taiwan's Mainland Affairs Council spokesperson Liang Wen-chieh said on Thursday that China's defence spending was far greater than Taiwan's.
"If they could place importance on cross-strait peace, this money could also be used to improve the mainland's economy and people's livelihoods," he said.
"The two sides of the strait would not then be like this, at daggers drawn; that would be good for everyone."
China's military operates almost daily in the waters and skies around Taiwan in what the government in Taipei says is part of Beijing's harassment and pressure campaign against it.
(Reporting by Beijing newsroom; Writing and additional reporting by Ben Blanchard in Taipei; Editing by Alison Williams, Kate Mayberry and Thomas Derpinghaus)
Japan's first female prime minister, Sanae Takaichi speaks during a press conference in Tokyo, Japan, on 21 October. (Photo: Eugene Hoshiko / Pool /EPA)