SlideShare a Scribd company logo
Programming in JAVA
BY
N.RUBA
ASST.PROF/DEPT. OF CA,
BON SECOURS COLLEGE FOR WOMEN,
THANJAVUR.
1
 Overview of Java Technology
 Java as a programming language
 Java as a platform
 Short history of the development of java
 Java as a new paradigm in programming
 Features of Java
 Comparing java and other languages
 Applications and Applets
CHAPTER-2
Introduction to Java Programming
2
 A program is a series of instructions that are carried out by a computer.
 Application programming is a programming process that is aimed at
developing an application.(e.g banking, railway .,etc)
 Systems programming- is the activity of writing, amending or extending
the operating system, which is a program that runs on the computer
hardware in order to allow other applications to be run.
Introduction 3
 Java is a general-purpose high-level object oriented programming language that
provides the following characteristics:
 Simple
 Object oriented
 Interpreted•
 Architecture-neutral
 Platform independent
 Multithread
 Dynamic
 High-performance
 Distributed
 Robust
 Secure.
Java as a programming language
4
 A programming language requires either a compiler or an interpreter to
translate a code written in high-level programming language (source code)
into its machine language (objectcode) equivalent.
 But, to run a Java program, Java uses a combination of compiler and
interpreter.
 The Java compiler translates the Java program into an intermediate code called
Java byte code.
 A Java interpreter is used to run the compiled Java byte code. This allows Java
programs to run on different platforms.
 A compiled Java byte code can be executed on any computer platform on
which the Java interpreter is installed.
 For each type of computer, a different Java interpreter is required to interpret
the Java byte code.
5
 Java is a strongly typed language. That means that every variable
(or expression) has a type associated with it and the type is
known at the time of compilation.
 In Java, data type conversions do not take place
implicitly.
 There are three kinds of Java program:
 Applications These are stand-alone programs that run on a
computer.
 Applets These are programs that run on a web browser.
Appletviewer is provided to ensure that these programs run
without a web browser.
 Servlets These are programs that run at the server side

6
JAVA as a compiler and Interpreter
Object code
Java Byte
code
interpreter
Java Source
code
Compiler
7
 A software and hardware environment in which a program runs is referred
to as a platform.
 Java platform that is compatible and executes on platforms based on
different hardwares.
 Java platform consists of
 Java Virtual Machine(JVM)
 Receives bytecode files and translates them into machine language(object code)
instructions.
 E.g Unix, linux & windows
 Java Applications Programming Interface(JavaAPI)
 Collection of software components
 API grouped in the form of packages
Java as a platform 8
 Java is a result of efforts of programmers in the early 1990s to develop a portable,
secure and scalable language to be used for communication between electronic
devices.
 A team of programmers led by James Gosling of Sun microsystems developed the first
version of Java called OAK.
 Java language was meant for programming the embedded systems in consumer
electronic devices
 Since the Oak trademark was already registered with some other organization, Sun
Microsystems renamed the language Java, in January 1995.
 During the period when Oak was being developed, the computer world witnessed the
emergence of the Internet. As Internet usage became widespread, the need for a
portable,secure programming language increased.
 Java fit the bill perfectly. Initially developed for use on different electronic devices, the
language was later adapted for Internet programming, Java met all the requirements
specified for web-based applications as it can be used to writeplatform-independent
code.
History of development of Java 9
 In 1995, Sun Microsystems released the first version of the Java Development Kit (JDK)and HotJava, a
Java-enabled browser.
 HotJava was capable of running Java applicationsin the form of Java Applets embedded in web pages, a
feature since taken up by browsers from Microsoft and Netscape. Java is often described as the World
Wide Web (www) programming language.
 From the second half of the 1990s, the popularity of Java increased considerably. An important
consequence of the evolution of Java is that it has grown into a full-scale development system.
 capable of being used for developing large applications that exist outside of the web (Internet)
environment that is, all kinds of program that run on a PC), including those that make extensive use of
networking to enable communication between programs.
 Sun Microsystems are now working to further refine and develop Java language.
In addition,they are also working on other Java tools and applications, Prominent among these are
thefollowing:
 Java Beans--the Java object component technology
 JavaServer-a complete web server application written in Java, supporting serviets.•
 JDBC-Java Database Connectivity, providing a Java-based interface to SQL databases.
 Java Workshop a Java programming environment for developing Java programs which isitself
written in Java.
 To get the latest updates on other Java tools and applications, readers can refer to the website of
Sun Microsystems-http://www.sun.com.
10
There are a number of other factors that are attributed to the rise in popularity of Java.
These include the following
 Familiarity of Java as a programming language to users of other popular languages,
notably C++ and Smalltalk: due to this factor, users find it simple and easy to relate
and comprehend.
 The Java development kit is offered free of cost
 This factor allows potential users to try out language with minimal start-up cost
 Its availability: Java is offered as freely downloadable software from the Sun
Microsystems website
 The software is also available on other websites
 Finally, its timing: Java gained popularity as it emerged at the right time when the
Internet was in its nascent stage and was all set to grow in popularity
Java as a new paradigm in programming
11
Features of Java
It is simple, it is highly robust, platform independent and portable
 Java is simple and Object Oriented Language
 Java is highly secure
 Allows to develop highly reliable software applications.
 Provides compile time checking and run time checking.
 Java makes memory management extremely simple
12
 Java compiler generates a byte code.
 Bytecode-special format
 Java byte code written in hexadecimal characters
 Byte code is completely platform- independent, only the interpreter and a few
native libraries need to be ported to get java run on a new computer or OS.
 The architectural –neutral and portable language platform of java is known as JVM-
Java Virtual Machine.
 Java shows a high performance
 Java is interpreted, threaded and dynamic
 Providing multi threading capability
 Multithreading in Java is a process of executing multiple
threads simultaneously.
 A thread is a lightweight sub-process, the smallest unit of processing.
Multiprocessing and multithreading, both are used to achieve multitasking.
13
 Java is dynamically linked
 Does not have an explicit link space.
 Java source code is divided into .java files
 Compiler complies these into .class files
 Other features of java – no pointers, all memory access is trusted
automatic memory allocation and deallocation
14
Comparing Java and other Languages
 Java is similar to C and C++, but is strongly typed
 Java is dynamically linked
 Java is case sensitive
 Java does not support pointer
 Java allows single inheritance
 Multiple inheritance can be achieved in java through interfaces
 Java is compiled and interpreted language
15
Applications and Applets
 Java program are compiled into applet or application
 Application are stand-alone program executed by virtual machine
 Applets are intended to be loaded into and interpreted by a browser, such
as Netscape or Internet explorer
 A byte code cannot be modified by a programmer
16
Java Applet
 Applet is a special type of program that is embedded in the webpage to generate the
dynamic content. It runs inside the browser and works at client side.
Advantage of Applet
 There are many advantages of applet. They are as follows:
 It works at client side so less response time.
 Secured
 It can be executed by browsers running under many platforms, including Linux, Windows,
Mac Os etc.
Drawback of Applet
 Plugin is required at client browser to execute applet.
How to run an Applet?
 There are two ways to run an applet
 By html file.
 By appletViewer tool (for testing purpose).
17
example of Applet by html file:
To execute the applet by html file, create an applet and compile it. After that create an
html file and place the applet code in html file. Now click the html file.
//First.java
import java.applet.Applet;
import java.awt.Graphics;
public class First extends Applet{
public void paint(Graphics g){
g.drawString("welcome",150,150);
}
}
Note: class must be public because its object is created by Java Plugin software that
resides on the browser.
18
myapplet.html
<html>
<body>
<applet code="First.class" width="300" height="300">
</applet>
</body>
</html>
 To execute the applet by html file, create an applet and compile it. After that create an html
file and place the applet code in html file. Now click the html file.
19
Simple example of Applet by appletviewer tool:
To execute the applet by appletviewer tool, create an applet that contains applet tag in comment and
compile it. After that run it by: appletviewer First.java. Now Html file is not required but it is for testing
purpose only.
//First.java
import java.applet.Applet;
import java.awt.Graphics;
public class First extends Applet{
public void paint(Graphics g){
g.drawString("welcome to applet",150,150);
}
}
/*
<applet code="First.class" width="300" height="300">
</applet>
*/
20
 To execute the applet by appletviewer tool, write in command prompt:
 c:>javac First.java
 c:>appletviewer First.java
21
 Special features of java program
 Access specifier
 Constructors
 Static
 The method main()
 The signature of the main method is
 Public staticvoid main(String args[])
22
Step 1:
Write a program on the notepad and save it with .java (for
example, DemoFile.java) extension.
class Demofile
{
public static void main(String args[]) {
System.out.println("Hello!");
System.out.println("Java");
}
}
23
Step 2:
Open Command Prompt.
Step 3:
Set the directory in which the .java file is saved. In our case, the .java
is saved in C:demo.
Step 4:
Use the javac command to compile the Java program. It generates a
.class file in the same folder. It also shows an error if any.
javac Demofile.java
step 5:
Use the following command to run the Java program:
c:> cd demo
c:> demo> javac Demofile.Java
c:> java Demofile
output:
Hello! Java
24
Thank you
25

More Related Content

PPTX
Java ms harsha
PPT
J2ee strutswithhibernate-140121221332-phpapp01
PPT
An introduction to java programming language forbeginners(java programming tu...
PPTX
Java Programming (M&M)
PPTX
Java Intro
PPTX
Java Lecture 1
PDF
130700548484460000
PPTX
Java v/s .NET - Which is Better?
Java ms harsha
J2ee strutswithhibernate-140121221332-phpapp01
An introduction to java programming language forbeginners(java programming tu...
Java Programming (M&M)
Java Intro
Java Lecture 1
130700548484460000
Java v/s .NET - Which is Better?

What's hot (19)

DOCX
Software environment
PDF
Java Programming Basics
DOCX
Software requirement
PDF
perl-java
PPTX
C,c++,java,php,.net training institute in delhi, best training institute for ...
PPTX
Features of java
PDF
(Ebook pdf) java programming language basics
PPTX
A Comparison of .NET Framework vs. Java Virtual Machine
PDF
Java Programming
PPTX
PPTX
Structure programming – Java Programming – Theory
PPT
Java features
PPTX
Presentación rs232 java
PPTX
Java (Part 2) unit 1
PDF
J introtojava1-pdf
PPTX
Core Java
 
DOCX
JAVA First Day
PDF
JAVA Program Examples
Software environment
Java Programming Basics
Software requirement
perl-java
C,c++,java,php,.net training institute in delhi, best training institute for ...
Features of java
(Ebook pdf) java programming language basics
A Comparison of .NET Framework vs. Java Virtual Machine
Java Programming
Structure programming – Java Programming – Theory
Java features
Presentación rs232 java
Java (Part 2) unit 1
J introtojava1-pdf
Core Java
 
JAVA First Day
JAVA Program Examples
Ad

Similar to Features of java unit 1 (20)

PPTX
Unit1- OOPJ Chapter-1 Object Oriented Programming JAVA.pptx
PPT
Servlets and JavaServer Pages (JSP) from the B.Sc. Computer Science and Infor...
PPTX
MODULE_1_The History and Evolution of Java.pptx
PPTX
JAVA ALL 5 MODULE NOTES.pptx
PPT
1.INTRODUCTION TO JAVA_2022 MB.ppt .
PPT
Core Java Slides
PPTX
Chapter-1 Introduction.pptx
PPSX
Introduction of java
PPT
Java presentation
PPTX
1 .java basic
PPT
Java ppt-class_Introduction_class_Objects.ppt
PPT
Java-Unit-I.ppt
PPTX
Introduction to java
PPTX
1.Intro--Why Java.pptx
PPT
Java ppt-class_basic data types methods definitions
PPTX
1_Introduction to Java.pptx java programming
PPTX
Module1_htryjtjhkrhdegtfhsfhrdgfhpart1.pptx
PPTX
Java
PPTX
Java session2
PPT
Chapter 1 introduction to java technology
Unit1- OOPJ Chapter-1 Object Oriented Programming JAVA.pptx
Servlets and JavaServer Pages (JSP) from the B.Sc. Computer Science and Infor...
MODULE_1_The History and Evolution of Java.pptx
JAVA ALL 5 MODULE NOTES.pptx
1.INTRODUCTION TO JAVA_2022 MB.ppt .
Core Java Slides
Chapter-1 Introduction.pptx
Introduction of java
Java presentation
1 .java basic
Java ppt-class_Introduction_class_Objects.ppt
Java-Unit-I.ppt
Introduction to java
1.Intro--Why Java.pptx
Java ppt-class_basic data types methods definitions
1_Introduction to Java.pptx java programming
Module1_htryjtjhkrhdegtfhsfhrdgfhpart1.pptx
Java
Java session2
Chapter 1 introduction to java technology
Ad

More from RubaNagarajan (19)

PPTX
Computer graphics-CRT.pptx
PPTX
Matrix representation- CG.pptx
PPTX
Personality development.pptx
PPTX
TRANSFORMATION-CG.pptx
PPTX
dda algorithm-cg.pptx
PPTX
line attributes.pptx
PPT
Java files and io streams
PPTX
Java -Exception handlingunit-iv
PPTX
Java Programming
PPTX
Introduction to Java -unit-1
PPTX
Constructors in C++
PPTX
Risks in cc
PPTX
Dreamweaver
PPT
Working principles of internet
PPT
Coreldraw
PPT
C programming
PPT
OPERATING SYSTEM
PDF
Virtualization in cloud computing
PDF
Cloud computing technology
Computer graphics-CRT.pptx
Matrix representation- CG.pptx
Personality development.pptx
TRANSFORMATION-CG.pptx
dda algorithm-cg.pptx
line attributes.pptx
Java files and io streams
Java -Exception handlingunit-iv
Java Programming
Introduction to Java -unit-1
Constructors in C++
Risks in cc
Dreamweaver
Working principles of internet
Coreldraw
C programming
OPERATING SYSTEM
Virtualization in cloud computing
Cloud computing technology

Recently uploaded (20)

PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
From loneliness to social connection charting
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Business Ethics Teaching Materials for college
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Module 3: Health Systems Tutorial Slides S2 2025
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
How to Manage Starshipit in Odoo 18 - Odoo Slides
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
PDF
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
From loneliness to social connection charting
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Business Ethics Teaching Materials for college
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
O5-L3 Freight Transport Ops (International) V1.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Week 4 Term 3 Study Techniques revisited.pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Module 3: Health Systems Tutorial Slides S2 2025
NOI Hackathon - Summer Edition - GreenThumber.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
Revamp in MTO Odoo 18 Inventory - Odoo Slides
STATICS OF THE RIGID BODIES Hibbelers.pdf
O7-L3 Supply Chain Operations - ICLT Program
UPPER GASTRO INTESTINAL DISORDER.docx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
How to Manage Starshipit in Odoo 18 - Odoo Slides
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf

Features of java unit 1

  • 1. Programming in JAVA BY N.RUBA ASST.PROF/DEPT. OF CA, BON SECOURS COLLEGE FOR WOMEN, THANJAVUR. 1
  • 2.  Overview of Java Technology  Java as a programming language  Java as a platform  Short history of the development of java  Java as a new paradigm in programming  Features of Java  Comparing java and other languages  Applications and Applets CHAPTER-2 Introduction to Java Programming 2
  • 3.  A program is a series of instructions that are carried out by a computer.  Application programming is a programming process that is aimed at developing an application.(e.g banking, railway .,etc)  Systems programming- is the activity of writing, amending or extending the operating system, which is a program that runs on the computer hardware in order to allow other applications to be run. Introduction 3
  • 4.  Java is a general-purpose high-level object oriented programming language that provides the following characteristics:  Simple  Object oriented  Interpreted•  Architecture-neutral  Platform independent  Multithread  Dynamic  High-performance  Distributed  Robust  Secure. Java as a programming language 4
  • 5.  A programming language requires either a compiler or an interpreter to translate a code written in high-level programming language (source code) into its machine language (objectcode) equivalent.  But, to run a Java program, Java uses a combination of compiler and interpreter.  The Java compiler translates the Java program into an intermediate code called Java byte code.  A Java interpreter is used to run the compiled Java byte code. This allows Java programs to run on different platforms.  A compiled Java byte code can be executed on any computer platform on which the Java interpreter is installed.  For each type of computer, a different Java interpreter is required to interpret the Java byte code. 5
  • 6.  Java is a strongly typed language. That means that every variable (or expression) has a type associated with it and the type is known at the time of compilation.  In Java, data type conversions do not take place implicitly.  There are three kinds of Java program:  Applications These are stand-alone programs that run on a computer.  Applets These are programs that run on a web browser. Appletviewer is provided to ensure that these programs run without a web browser.  Servlets These are programs that run at the server side  6
  • 7. JAVA as a compiler and Interpreter Object code Java Byte code interpreter Java Source code Compiler 7
  • 8.  A software and hardware environment in which a program runs is referred to as a platform.  Java platform that is compatible and executes on platforms based on different hardwares.  Java platform consists of  Java Virtual Machine(JVM)  Receives bytecode files and translates them into machine language(object code) instructions.  E.g Unix, linux & windows  Java Applications Programming Interface(JavaAPI)  Collection of software components  API grouped in the form of packages Java as a platform 8
  • 9.  Java is a result of efforts of programmers in the early 1990s to develop a portable, secure and scalable language to be used for communication between electronic devices.  A team of programmers led by James Gosling of Sun microsystems developed the first version of Java called OAK.  Java language was meant for programming the embedded systems in consumer electronic devices  Since the Oak trademark was already registered with some other organization, Sun Microsystems renamed the language Java, in January 1995.  During the period when Oak was being developed, the computer world witnessed the emergence of the Internet. As Internet usage became widespread, the need for a portable,secure programming language increased.  Java fit the bill perfectly. Initially developed for use on different electronic devices, the language was later adapted for Internet programming, Java met all the requirements specified for web-based applications as it can be used to writeplatform-independent code. History of development of Java 9
  • 10.  In 1995, Sun Microsystems released the first version of the Java Development Kit (JDK)and HotJava, a Java-enabled browser.  HotJava was capable of running Java applicationsin the form of Java Applets embedded in web pages, a feature since taken up by browsers from Microsoft and Netscape. Java is often described as the World Wide Web (www) programming language.  From the second half of the 1990s, the popularity of Java increased considerably. An important consequence of the evolution of Java is that it has grown into a full-scale development system.  capable of being used for developing large applications that exist outside of the web (Internet) environment that is, all kinds of program that run on a PC), including those that make extensive use of networking to enable communication between programs.  Sun Microsystems are now working to further refine and develop Java language. In addition,they are also working on other Java tools and applications, Prominent among these are thefollowing:  Java Beans--the Java object component technology  JavaServer-a complete web server application written in Java, supporting serviets.•  JDBC-Java Database Connectivity, providing a Java-based interface to SQL databases.  Java Workshop a Java programming environment for developing Java programs which isitself written in Java.  To get the latest updates on other Java tools and applications, readers can refer to the website of Sun Microsystems-http://www.sun.com. 10
  • 11. There are a number of other factors that are attributed to the rise in popularity of Java. These include the following  Familiarity of Java as a programming language to users of other popular languages, notably C++ and Smalltalk: due to this factor, users find it simple and easy to relate and comprehend.  The Java development kit is offered free of cost  This factor allows potential users to try out language with minimal start-up cost  Its availability: Java is offered as freely downloadable software from the Sun Microsystems website  The software is also available on other websites  Finally, its timing: Java gained popularity as it emerged at the right time when the Internet was in its nascent stage and was all set to grow in popularity Java as a new paradigm in programming 11
  • 12. Features of Java It is simple, it is highly robust, platform independent and portable  Java is simple and Object Oriented Language  Java is highly secure  Allows to develop highly reliable software applications.  Provides compile time checking and run time checking.  Java makes memory management extremely simple 12
  • 13.  Java compiler generates a byte code.  Bytecode-special format  Java byte code written in hexadecimal characters  Byte code is completely platform- independent, only the interpreter and a few native libraries need to be ported to get java run on a new computer or OS.  The architectural –neutral and portable language platform of java is known as JVM- Java Virtual Machine.  Java shows a high performance  Java is interpreted, threaded and dynamic  Providing multi threading capability  Multithreading in Java is a process of executing multiple threads simultaneously.  A thread is a lightweight sub-process, the smallest unit of processing. Multiprocessing and multithreading, both are used to achieve multitasking. 13
  • 14.  Java is dynamically linked  Does not have an explicit link space.  Java source code is divided into .java files  Compiler complies these into .class files  Other features of java – no pointers, all memory access is trusted automatic memory allocation and deallocation 14
  • 15. Comparing Java and other Languages  Java is similar to C and C++, but is strongly typed  Java is dynamically linked  Java is case sensitive  Java does not support pointer  Java allows single inheritance  Multiple inheritance can be achieved in java through interfaces  Java is compiled and interpreted language 15
  • 16. Applications and Applets  Java program are compiled into applet or application  Application are stand-alone program executed by virtual machine  Applets are intended to be loaded into and interpreted by a browser, such as Netscape or Internet explorer  A byte code cannot be modified by a programmer 16
  • 17. Java Applet  Applet is a special type of program that is embedded in the webpage to generate the dynamic content. It runs inside the browser and works at client side. Advantage of Applet  There are many advantages of applet. They are as follows:  It works at client side so less response time.  Secured  It can be executed by browsers running under many platforms, including Linux, Windows, Mac Os etc. Drawback of Applet  Plugin is required at client browser to execute applet. How to run an Applet?  There are two ways to run an applet  By html file.  By appletViewer tool (for testing purpose). 17
  • 18. example of Applet by html file: To execute the applet by html file, create an applet and compile it. After that create an html file and place the applet code in html file. Now click the html file. //First.java import java.applet.Applet; import java.awt.Graphics; public class First extends Applet{ public void paint(Graphics g){ g.drawString("welcome",150,150); } } Note: class must be public because its object is created by Java Plugin software that resides on the browser. 18
  • 19. myapplet.html <html> <body> <applet code="First.class" width="300" height="300"> </applet> </body> </html>  To execute the applet by html file, create an applet and compile it. After that create an html file and place the applet code in html file. Now click the html file. 19
  • 20. Simple example of Applet by appletviewer tool: To execute the applet by appletviewer tool, create an applet that contains applet tag in comment and compile it. After that run it by: appletviewer First.java. Now Html file is not required but it is for testing purpose only. //First.java import java.applet.Applet; import java.awt.Graphics; public class First extends Applet{ public void paint(Graphics g){ g.drawString("welcome to applet",150,150); } } /* <applet code="First.class" width="300" height="300"> </applet> */ 20
  • 21.  To execute the applet by appletviewer tool, write in command prompt:  c:>javac First.java  c:>appletviewer First.java 21
  • 22.  Special features of java program  Access specifier  Constructors  Static  The method main()  The signature of the main method is  Public staticvoid main(String args[]) 22
  • 23. Step 1: Write a program on the notepad and save it with .java (for example, DemoFile.java) extension. class Demofile { public static void main(String args[]) { System.out.println("Hello!"); System.out.println("Java"); } } 23
  • 24. Step 2: Open Command Prompt. Step 3: Set the directory in which the .java file is saved. In our case, the .java is saved in C:demo. Step 4: Use the javac command to compile the Java program. It generates a .class file in the same folder. It also shows an error if any. javac Demofile.java step 5: Use the following command to run the Java program: c:> cd demo c:> demo> javac Demofile.Java c:> java Demofile output: Hello! Java 24