0% found this document useful (0 votes)
5 views2 pages

Java: Machine Independent Programming Guide

Uploaded by

karanayanava2011
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Java: Machine Independent Programming Guide

Uploaded by

karanayanava2011
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Java Is a Machine Independent Programming

language
Java is machine independent programming language. A java program
can run on any system without any modification regardless the OS or
hardware. This is possible The Java Virtual Machine (JVM) reads this
bytecode and translates it into machine-specific code. This allows the
same .class file to run on any platform that has a JVM, making Java a
'Write Once, Run Anywhere' language. A Java program can run on
different systems without requiring modifications to suit the OS or
hardware.

Importnce of path setting


To run Java commands like 'java' or 'javac' from any directory, the
system needs to know where Java is installed. Setting the PATH
environment variable tells the system where to find these things
1. Go to command prompt- type “java -version” if the version cannot be
seen then there is no path created for it
2. Path settings-
a) Finding the path-
Go to c drive and find “Program files” and find java and and inside java
find jdk or jre ,go to the jdk or jre file and copy the path from the top bar
(example: c:\program files\java\jdk-XX)
b) Creating a path:
Go to environment settings. Click on new and there create a file .
'JAVA_HOME' is a standard environment variable that points to your
Java installation directory. Find a file named “Path” there and double
click. Inside create another file named “%JAVA_HOME%\bin”. Finish
and exit.
3. Go to command prompt and type “java -version” now you should see
the version as there is a path created for it
.

Activity
A java code gets Compiles into a java class and it gets ready to run
This is made possible because the Java Virtual Machine (JVM) reads
the bytecode and translates it into machine-specific instructions.
Here is an activity to run a program in notepad
Steps to run a program in note pad:

Using notepad and command prompt


Here Notepad is used as a simple text editor to write Java code. The
Command Prompt is used to compile and execute the code using Java
commands.

Writing the program


Class to be written and saved as a .java file. Create a text document and
type the program (creating files in desktop is recommended the most)
Format : <class name>.java
Example-“[Link]” if Hello is the class name in the program. This file
is human readable

Complilation of program
Open the command prompt from desktop if the .java file was created in
desktop. Using the command 'javac <filename>.java', the code is
compiled into bytecode (.class file). Bytecode is not human-readable and
is not machine-specific. Example- javac Hello (this will compile the
program)

Execution of program
Using the command 'java <classname>', the JVM interprets and runs the
bytecode. Example- java Hello(this will run the program) As a result, the
same .class file works on any platform that has a JVM.

Conclusion
This helps us to understand how java programs are written, compiled
and run using basic tools like notepad and command prompt, It shows
how java works behind the scenes. This method is typically used to
understand the process of program execution and to show that java is a
machine independent language

You might also like