Java is a compiled language (like C, Fortran, etc.). it can run in most any OS. It is now supported by Oracle. It does have security problems. But it is now used almost exclusively in well protected, closed systems, often not even connected to the web. Last major use I know of was in some games.
javascript is, by definition, a "scripting" language (like AppleScript, PHP, Python, etc.). It is used (and abused) on the web to do things that plain html cannot. It is also a major vector for malware and accessing things on your computer, behind your back, of course. It must have a browser to allow it to run. Thankfully, CSS3+ and HTML5 are making it less needed. It's the main reason I keep ad blockers running.
The two things are completely different 'animals'. I usually use a lowercase "j" for javascript to imply my disdain for it as opposed to a capital "J" since it is a commercial product.
Handy things javascript can do: Transmitting information about the user's reading habits and browsing activities to various websites. Web pages frequently do this for Web analytics, ad tracking, personalization or other purposes. See the "Security" section on <
this Wikipedia page>. Additional, simpler explanations at <
WhatIsMyBrowser.com>.