

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This handout explains the concept of write once run anywhere (wora) in java programming, focusing on java virtual machine (jvm) and java bytecode. It covers how java source code is compiled into bytecode, the role of jvm in executing bytecode, and the availability of jvms for various operating systems and cpus. It also introduces the java runtime environment (jre) and its importance in running java software.
Typology: Lecture notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Web Design & Development CS-
When you write a program in C++ it is known as source code. The C++ compiler converts this source code into the machine code of underlying system (e.g. Windows) If you want to run that code on Linux you need to recompile it with a Linux based compiler. Due to the difference in compilers, sometimes you need to modify your code.
Java has introduced the concept of WORA (write once run anywhere). When you write a java program it is known as the source code of java. The java compiler does not compile this source code for any underlying hardware system, rather it compiles it for a software system known as JVM (This compiled code is known as byte code). We have different JVMs for different systems (such as JVM for Windows , JVM for Linux etc). When we run our program the JVM interprets (translates) the compiled program into the language understood by the underlying system. So we write our code once and the JVM runs it everywhere according to the underlying system.
This concept is discussed in detail below
Java Compiler javac
Java Byte Code
Source Code
Java Interpreter
Machine Code
Web Design & Development CS-
Java programs (Source code) are compiled into a form called Java bytecodes.
The Java compiler reads Java language source (.java) files, translates the source into Java bytecodes, and places the bytecodes into class (.class) files.
The compiler generates one class file for each class contained in java source file.
The central part of java platform is java virtual machine
Java bytecode executes by special software known as a "virtual machine".
Most programming languages compile source code directly into machine code, suitable for execution
The difference with Java is that it uses bytecode - a special type of machine code.
The JVM executes Java bytecodes, so Java bytecodes can be thought of as the machine language of the JVM.
JVM are available for almost all operating systems.
Java bytecode is executed by using any operating system’s JVM. Thus achieve portability.