You can install NoScript Firefox Extension and add the websites on which you want to allow Java to the whitelist. It will block Java (among other things) on all other websites. You will probably want to globally allow JavaScript (in NoScript), otherwise most websites will be broken. Install it and see the available options. Read documentation too.
https://addons.mozilla.org/en-US/firefox/addon/noscript/
You can also configure Java to ask the user before it runs in the browser. Furthermore, you can remove all CA certificates from Java and only add the one that is used to sign your Java applications. You can do all this in Java control panel.