There were many wars between Japan and China before the first sino-Japanese war.
/u/Klaus_Von_Ha refers to the invasion of Korea by Toyotomi Hideyoshi, that involved the Ming armies and after the conquest of Korea (in less than two month) most of the regular battles involved Japanese soldiers facing Ming soldiers. Besides, the admited goal of Toyotomi Hideyoshi was to conquer China.
We can also think about the "Mongol invasions of Japan", that opposed the Yuan Dynasty led by the mongols, but considered a Chinese dynasty, facing the Kamakura shogunate, in 1274 and 1281.
But even before that, during the Korean Three kingdoms, Japanese armies faced Chinese armies when they both intervened on the Korean peninsula (Japan was allied to Goguryo and Baekce, China was allied with Silla).
Although I can't say if it was the earliest war with China, Japan invaded Korea twice in the 1590's.
Under the leadership of Toyotomi Hideyoshi (although actually led by daimyo on the ground), Japan invaded Korea with 158,000 men in 1592 and with 140,000 in 1597.
The Making of Modern Japan - Marius B. Jansen p.18
The 1592 invasion army:
"overran most of Korea in the early stages of the fighting, and on several occasions defeated Chinese armies sent to defeat them"
A History of Japan - R.H.P Mason/J.G Caiger
The question in my eyes is really "How far back does it count?"
Most people in Japan see the Nihon shoki as the earliest historical document of Japan. (Apparently this text is mainly old school propaganda that legitimizes the Emperor line and there is earlier stuff but hear me out.) In the earlier parts of the text it chronicles their fights with the real native Japanese known as the Ainu who are basically extinct. The first emperor was in 660 BC. Thing is, before this the text has this big long creation myth about how the Emperor and everything else was created by the gods etc. etc. etc. that makes it sound like it was their country in the first place even though no one really believes that anymore. Nowadays we know (but Japanese hate to admit) that their bloodline is some blend of people that came from Mongolia, China and Korea.
So, the short of it is that in my eyes there has been this sort of conflict going on since at least 2700 years ago. It's just that the descendants of those who invaded and conquered Japan gradually came to see themselves as what we now call "Japanese".