Well, it's Ubuntu 14, which is now in Extended Maintenance mode. Which means you get security updates, but I don't know if there is a way to update your Java on Ubuntu 14. It doesn't appear on
https://packages.ubuntu.com/.
I would definitely upgrade the OS first; the update of your Java is probably a breeze after that.
By the way, what do you mean by "Java"? The browser plugin? The runtime environment? The development kit? Something else?
Also, there is an Oracle version of Java and an open source version named OpenJDK.
In short, you need to provide more information about what exactly you want to update. But as I said, my recommendation is to first upgrade the OS.