Java Vs JavaScript

Java vs Javascript? What the heck is the difference between Java and JavaScript? It is interesting how people, even those in the industry, don't understand the difference between Java and JavaScript. Quite often people refer to JavaScript as Java. I've even heard people say the word "Java" as if it was short for JavaScript.

Just starting to learn JavaScript? Try this: JavaScript Tutorial for Beginners.

You can see the JavaScript code when you go to View > Source (Internet Explorer) or View > Page Source (FireFox). That's JavaScript. Java can also be on Web pages but the Java code will not be seen there.

Here is a quick list of the basic similarities and differences between Java and JavaScript:

  • JavaScript was created to make web pages more interactive.
  • JavaScript contains a much smaller and simpler set of commands than Java. It is fairly easy for the guy who loves to tinker around with web pages. JavaScript was created with the idea that web designers who know HTML would be using it. Learning HTML should be a prerequisite to learning JavaScript.
  • Java is a much larger and more complicated language. Java has a full-featured set of commands that allow a programmer to create almost any program. In addition, these full-featured programs can run on almost any machine.
  • Many of Java and JavaScript's programming structures are similar.
  • JavaScript was created to add interactivity to web pages.
  • Some things you can do with JavaScript: Slide shows, making sure people fill out forms properly, displaying different web page content depending on the browser, storing and retrieving small bits of information (known as cookies) from the visitor's browser and many other interactive things.
  • A little Java program on a web page, also known as a Java "Applet" can stand on its own. An applet is a complete, fully-contained program.
  • JavaScript must do its work inside an HTML document. JavaScript cannot stand on its own.
  • JavaScript is text that is read by a browser, processed by the browser and then enacted by the browser.
  • A Java-enabled browser is not automatically a JavaScript-enabled browser. The two technologies are entirely separate.
  • JavaScript loads very quickly on a web page.
  • Java takes much longer to load.
  • Java applets are downloaded as separate files to your computer and run separately of HTML files and images.
  • You can use JavaScript to manipulate any of the HTML elements on a Web page.
  • JavaScript is not based on Java in any way. Originally, it was going to be called "LiveScript." The name was changed thinking that it would be associated with Java in people's minds (a popular language). It was basically a marketing move.

This site is for beginning web page builders. It is likely that you are interested in JavaScript and Java only as pre-made functionality that can be cut and pasted into a web page. I hope you understand more about the "ins and outs" of Java vs Javascript now. Here is more Java vs JavaScript info if you feel the need.

Website Building Tip

Some things you can do with JavaScript: Slide shows, making sure people fill out forms properly, displaying different web page content depending on the browser, storing and retrieving small bits of information (known as cookies) from the visitor's browser and many other interactive things.

A Simple JavaScript Script