What is the difference between Java and JavaScript?

Updated: 01/24/2018 by Computer Hope

Java logoJava and JavaScript are programming languages used to develop applications or features on a web page. While the programming code itself has some similarities, there are differences between them.

The biggest difference is the type of applications they are used to create. Java programming is for applications that are either run from a computer desktop or initiated through a web page. They are standalone programs and open a separate program window in most cases. If Java is not installed, a computer cannot run Java applications. However, JavaScript is included with all modern browsers and as long as it is enabled will execute the JavaScript when the web page is loaded.

JavaScript or JS logoJavaScript programming lives in a web page, and either provides additional features in the web page or may create an application in the web page itself. Some video games have been developed using JavaScript, and they can be played right in the Internet browser window.

Java programs typically perform calculations and the main "thinking" process on the server-side or in a Java applet that must be downloaded first. JavaScript code, on the other hand, performs calculations and its "thinking" is always on the client side, the computer where the web page is accessed. For this reason, JavaScript code is often faster, sometimes almost instant. Java programs take a little bit of time (several seconds or more) to process.

Java programs can sometimes require a lot of computer memory to function properly, which can cause a computer to slow down or another program to operate more slowly. While Java programs can be developed to do very powerful things, the higher memory usage is a disadvantage. JavaScript, however, uses less memory (very little in some cases) to do its processing and function properly. It is a common programming language used in many web pages today (including this one) because of its low memory requirement and ability to provide many different features on a web page.

Examples of JavaScript code

Below is an example of JavaScript code in HTML code.


<p>Click the button to display an alert box.</p>

<button onclick="myfunction();">Try it</button>

function myfunction() {
	alert("Clicking the button pops up an alert box!");


The above code gives you something similar to the below "Try it" button. When you click this button an alert box will appear.

Examples of Java Code

import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.feed.synd.SyndFeed;
import or.xml.sax.ImputSource;

public class RSSReader {

  public static void main(String[] args) {
	if (args.length == 0) {
		System.err.println("usage: java RSSReader URL");
	string feedURL = args[0];
	SyndFeedInput feedInput;
	feedInput = new SyndFeedInput();
	SyndFeed feed = null;
	try {
		feed = feedInput.build(new InputSource(feedURL));
	catch (Exception e) {
		System.err.println("Unable to prase feed from: " + args[0]);
	System.out.println("Found a feed of type " + feed.getFeedType());
	System.out.println("Feed title: " + feed.getTitle());

Additional information