0% found this document useful (0 votes)
8 views

Java Coding

The document outlines the steps to create, compile, and run a simple Java program. It describes creating source code in an editor, using the javac compiler to compile it, and running the bytecode with the java interpreter. It also discusses using IDEs like Eclipse or NetBeans for Java development and provides tutorial links.

Uploaded by

eclair636
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Java Coding

The document outlines the steps to create, compile, and run a simple Java program. It describes creating source code in an editor, using the javac compiler to compile it, and running the bytecode with the java interpreter. It also discusses using IDEs like Eclipse or NetBeans for Java development and provides tutorial links.

Uploaded by

eclair636
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

THE JAVA DEVELOPMENT PROCESS

Step1: Write the Java source code

Step2: Compile the Java source code

Step3: Run the compiled Java code or class file

1
A Simple Java Program

//This program prints Welcome to Java!


public class Welcome {
public static void main(String[] args) {
System.out.println("Welcome to Java!");
}
}

2
Java Development tools

• You can use a text editor, to create Java Programs and to compile and
run the programs from the command windows.
• You can use a Java development tool
• NetBeans, Eclipse
• Integrated development environment(IDE)
• quick, effective
• Self-study tutorials
• Java Fundamentals I- Introduction to NetBeans IDE, Part 1
• https://www.youtube.com/watch?v=Hv2yvXTVTVo
• Eclipse IDE Tutorial:
• https://www.youtube.com/watch?v=23tAK5zdQ9c

3
Step 1:Creating and Editing Using NotePad++

4
Creating, Compiling, and
Running Programs
Create/Modify Source Code

Source code (developed by the programmer)


Saved on the disk
public class Welcome {
public static void main(String[] args) {
System.out.println("Welcome to Java!"); Source Code
}
}

Compile Source Code


Byte code (generated by the compiler for JVM i.e., javac Welcome.java
to read and interpret, not for you to understand)

Method Welcome() If compilation errors
0 aload_0 stored on the disk

Bytecode
Method void main(java.lang.String[])
0 getstatic #2 …
3 ldc #3 <String "Welcome to
Java!">
5 invokevirtual #4 …
8 return Run Byteode
i.e., java Welcome

Result

5 If runtime errors or incorrect result


Step 2: To compile your program

Type JDK Command:


javac Welcome.java

where javac is JDK Java compiler.


•Compiler translates the source program into Java bytecode.
•The compiler saves the bytecode into the file Welcome.class. 6
Step 3: To run the byte code with the Java
interpreter
Successful compilation will create the bytecode class file: Welcome.class

Type JDK Command : java Welcome


The class file (bytecode) is loaded into memory and interpreted by the Java Virtual
Machine (JVM)

7
Trace a Program Execution
Enter main method

//This program prints Welcome to Java!


public class Welcome {
public static void main(String[] args) {
System.out.println("Welcome to Java!");
}
}

8
Trace a Program Execution

Execute statement

//This program prints Welcome to Java!


public class Welcome {
public static void main(String[] args) {
System.out.println("Welcome to Java!");
}
}

print a message
to the console

9
Download eclipse
Eclipse IDE quick start

You might also like