Java is a general purpose programming language designed with one mantra in mind—”write once, run anywhere.”
Java applications are compiled into bytecode that can run on implementations of the Java Virtual Machine (JVM).
JVM helps bridge the gap between source code and the 1s and 0s that the computer understands. Any machine that has the JVM installed can run Java.
In web development, Java features most prominently as a server-side language and the programming language of choice for mobile apps on the Android platform.
It also still has a decent presence on the front-end as a Java applet, although this is falling out of favor due to security concerns.

Alongside HTML and CSS, JavaScript (standardized as ECMAScript) is considered one of the big three core components of the web. Employed by a majority of websites, JavaScript is a scripting language that typically runs in the browser and makes web pages dynamic and interactive.
Today JavaScript is also quickly growing as a server-side technology since the release of Node.js in 2009.

As different as they are, there are some top level similarities worth considering, especially if you are looking at web development when comparing Java to JavaScript.

Object-Oriented Programming (OOP). Both languages require the developer to code in terms of objects and their relationships to one another. By extension this gives both languages access to techniques like inheritance, encapsulation, and polymorphism.
Front-End Development. Both languages can be used in aspects of front-end development. JavaScript can be embedded directly into HTML, implemented as a framework or library; Java can be used as a Java applet.
Back-End Development. Both languages can be used on the server-side. Java has long been used to power back-end technologies like Apache, JBoss, and WebSphere. Node.js has become a launch pad for JavaScript-powered servers.

Java is strongly typed language and variable must be declare first to use in program.In Java the type of a variable is checked at compile-time.
Java is an object oriented programming language.
Java applications can run in any virtual machine(JVM) or browser.
Objects of Java are class based even we can’t make any program in java without creating a class.
Java program has file extension “.Java” and translates source code into bytecodes which is executed by JVM(Java Virtual Machine).
Java is a Standalone laguage.
Java program uses more memory.
Java has a thread based approach to concurrency.

JavaScript is weakly typed language and have more relaxed syntax and rules.
JavaScript is an object based scripting language.
JavaScript code run on browser only as JavaScript is developed for browser only.
JavaScript Objects are prototype based.
JavaScript file has file extension “.js” and it is interpreted but not compiled,every browser has the Javascript interpreter to execute JS code.
contained within a web page and integrates with its HTML content.
JavaScript requires less memory therefore it is used in web pages.
Javascript has event based approach to concurrency.