If you used setup assistant or migration assistant, more than likely it followed you.
That postition on the Dock makes it look like it recently used
. https://www.tekrevue.com/tip/recent-applications-extra-icons-mojave-dock/
Java has not been include with Mac since OS X 10.7
Get Java for your Mac - Apple Support
You can control click the icon to see if it is there on log-in and of course you can drag the icon off the Dock
From the terminal window you can copy and paste:
java -versiion
to see JAVA dependency you can , copy and paste:
find /Applications -type f -name *.jar
If you don't use Java you can uninstall it:
How to Uninstall Java on a Mac - OSXDaily
>System Preferences>JAVA you may be able to uninstall from here as well.