Information Technology Division

Javascript and Java: What's the Difference?

BY Melody Yan - Graduate Assistant

A common misconception about JavaScript is that it is an easier-to-use, scaled-down version of Java. This can't be farther from the truth.

JavaScript, developed by Netscape, is a smaller language that does not create applets or standalone applications. In its most common form today, JavaScript resides inside HTML documents, and can provide levels of interactivity far beyond typically flat HTML pages -- without the need for server-based CGI (Common Gateway Interface) programs. JavaScript runs inline, on the client-side.

Java, developed under the Sun Microsystems brand, is a full-fledged object-oriented programming language that must be compiled in order to run. It can be used to create standalone applications and a special type of mini application, called an applet. Applets are downloaded as separate files to your browser alongside an HTML document, and provide an infinite variety of added functionality to the Web site you are visiting. The displayed results of applets can appear to be embedded in an HTML page (e.g., the scrolling banner message that is so common on Java-enhanced sites), but the Java code arrives as a separate file.

The main difference between the two languages is that JavaScript was developed specifically to provide a level of interaction to previously static web pages - and thus acts like an extension to HTML.
Java, meanwhile, is a stand alone language which can be used on web sites - but ultimately is a much broader programming language with more in common to C++ than HTML.

Interestingly, JavaScript has become a mainstay in the Web design world, used regularly to control a variety of features on Web sites. Java, on the other hand, has receded from the Web as a tool of choice. With the exception of a few small Java applets (mini applications), Java as a full programming language is simply too cumbersome to be as effective as the fast client-side JavaScript. Java itself has become more useful for general programming purposes-but its use as a tool to add design features to Web pages is quickly going out of style.

To learn more about JavaScript, you can access the following links:

MTSU Javascript Tutorials

http://javascript.internet.com

http://www.javascript.com