Java is to JavaScript as car is to carpet.
Java is not JavaScript!
Java is a high-level programming language developed by Sun Microsystems. Java was originally called OAK, and was designed for handheld devices and set-top boxes. Java is an object-oriented language similar to C++, but simplified to eliminate language features that cause common programming errors. Java source code files (files with a .java extension) are compiled into a format called bytecode (files with a .class extension), which can then be executed by a Java interpreter.
JavaScript is a scripting language developed by Netscape to enable Web authors to design interactive sites. JavaScript can interact with HTML source code, enabling Web authors to spice up their sites with dynamic content.
The change of name from LiveScript to JavaScript happened at roughly the same time Netscape was including support for Java technology in its Netscape Navigator browser. Consequently, the change proved a source of much confusion. There is no real relation between Java and JavaScript; their only similarities are some syntax and the fact that both languages are used extensively on the World Wide Web.