JavaScript is not technically considered a programming language. Rather, JavaScript is purely a scripting language that allows an HTML developer to add processing functionality to a webpage. JavaScript can react to input and display output on a Web page. A script is written directly into the HTML and is interpreted by the user's Web browser at the same time as the HTML. Despite the name, JavaScript is not related in any way to Java.
Java is a programming language developed to run in a virtual machine. This allows Java applets, small independent programs designed for a single task, to be run on almost any platform that has a Java virtual machine installed. This creates a liaison between the program and the environment. A programmer would only have to develop one version of the program and any platform with a virtual machine would be able to run that program. Java must be compiled into machine language before it can be used. When used in conjunction with HTML, the HTML does nothing more than call the applet, sending it to the client computer. The client computer loads the applet into the virtual machine in order for it to be run.
One way of differentiating the two is that Java is an object-oriented language and JavaScript is an object-based language. The difference here is very subtle. Both languages treat "program "elements — such as a text field or a pop-up window — as objects, which can pass instructions to one another. But a true object-oriented language, as Java is, also makes heavy use of inheritance: Objects can be extended by inheriting functionality from existing objects and adding new attributes. JavaScript does not have this ability; with JavaScript, objects can be created, but cannot inherit properties. Object-oriented languages can also make use of encapsulation, overloading and polymorphism.