0% found this document useful (0 votes)
18 views1 page

JL Exp01

Uploaded by

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

JL Exp01

Uploaded by

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

AICE, Computer Science Dept. (CS/AI 4th Sem) PROGRAMMING IN JAVA.

EXPERIMENT NO 1
AIM :- To write first program in java

We break the process of programming in Java into three steps:


1. Create the program by typing it into a text editor and saving it to a file named,
say, MyProgram.java.
2. Compile it by typing "javac MyProgram.java" in the terminal window.
3. Execute (or run) it by typing "java MyProgram" in the terminal window.

Creating a Java program :. A program is nothing more than a sequence of characters,


like a sentence, a paragraph, or a poem. To create one, we need only define that
sequence characters using a text editor in the same way as we do for
email. HelloWorld.java is an example program. Type these characters into your text
editor and save it into a file named HelloWorld.java.
public class HelloWorld {
public static void main(String[] args) {
// Prints "Hello, World" in the terminal window.
System.out.println("Hello, World");
}
}
Compiling a Java program :. A compiler is an application that translates programs from
the Java language to a language more suitable for executing on the computer. It takes a
text file with the .java extension as input (your program) and produces a file with
a .classextension (the computer-language version). To compile HelloWorld.java type the
boldfaced text below at the terminal. (We use the %symbol to denote the command
prompt, but it may appear different depending on your system.)
% javac HelloWorld.java
If you typed in the program correctly, you should see no error messages. Otherwise, go
back and make sure you typed in the program exactly as it appears above.
Executing (or running) a Java program : Once you compile your program, you can
execute it. This is the exciting part, where the computer follows your instructions. To
run the HelloWorld program, type the following in the terminal window:
% java HelloWorld
If all goes well, you should see the following output

Hello, World

1|P ag e
Rajendra Singh
(Assistant Professor)

You might also like