Presentation is loading. Please wait.

Presentation is loading. Please wait.

Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.

Similar presentations


Presentation on theme: "Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with."— Presentation transcript:

1 Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with two different ways:  By using Command prompt  By using IDE()’s  By using Command prompt:  Type the code in any text editor software(i.e. Notepad in windows ).  Save the file with.java extension.  Run on command prompt.  By using IDE’s:  An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of a source code editor, build automation tools and a debugger i.e. jcreator.

2 Execution ways of program References:  List of Java IDE’s:  NetBeans  Eclipse  IntelliJ IDEA Community Edition  Android Studio  Enide Studio 2014  BlueJ  jEdit  jGRASP  Jsource  Jdeveloper  DrJava

3 Program: First Java Program

4 First java program References:  To run first simple “Hello” program three steps are required:  Create the program by typing it into a text editor and saving it to a file named, say, Hello.java.  Compile it by typing "javac Hello.java" in the terminal window.  Run (or execute) it by typing "java Hello" in the terminal window.

5 First java program References:  Creating a Java program: public class Hello { public static void main(String[] args) { System.out.println("Hello World!"); }

6 First java program References:  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 and produces a file with a.class extension (the computer-language version).  To compile Hello.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 Hello.java

7 First java program References:  Executing a Java program:  To execute or run a java program we need interpreter “java”.  It takes a class file with the.class extension as input.  % java Hello.java 

8 First java program References:  Explanation of Hello.java  class:  This keyword used to declare class. Name of class (Hello) followed by this keyword.  Hello:  Hello is the identifier and it is the name of the class.  public : Access Modifier  static:  static is reserved keyword which means that a method is accessible and usable even though no objects of the class exist.

9 First java program References:  Explanation of Hello.java  void:  This keyword declares nothing would be returned from method. Method can return any primitive or object.  main:  It is the name of method from where execution of the program starts.  ( )  The parentheses contain the variables called parameters followed by the method. If you want to pass any information then these parameters are used.  String arg[]:  It declares a parameter having name “arg”, which is an array of instances of the class “String”.

10 First java program Program: Java 0010Java001_HelloExample  Explanation of Hello.java  System:  It is name of Java utility class.  out:  It is an object which belongs to System class.  print:  It is a method which displays the string passed to it.  println:  It is same as “print” method but only difference is that after displaying the string it send the cursor to next line.  ;(Semicolon)  Each statements in Java are ends with semicolon.

11 Program: Java Program Structure

12 References: https://technoleaf.wordpress.com/category/java-basic/java-program-structure/

13 Java Program Structure References: https://technoleaf.wordpress.com/category/java-basic/java-program-structure/  DOCUMENTATION SECTION:  It is a set of comment lines giving the  name of the program,  the author and the other details,  which the programmer would like to refer.  PACKAGE STATEMENT:  The first statement allowed in Java files is a package statement.Thisstatement declares a package name and informs the compiler that the classes defined here belong to this package.  Ex: package student; It is optional because no need & our class to be part of packages.

14 Java Program Structure References: https://technoleaf.wordpress.com/category/java-basic/java-program-structure/  IMPORT STATEMENT:  Similar to #include statement in C. Ex: import student.test;  This statement instructs the interpreter to load the test class contained in package student.  Using import statement,we can access to classes that part of other named packages.  INTERFACE STATEMENT:  Interface like class but includes group of methods declaration. Used when we want to implement multiple inheritance feature.

15 Java Program Structure References: https://technoleaf.wordpress.com/category/java-basic/java-program-structure/  CLASS DEFINITION:  Java program may contain multiple class definition.  Classes are primary feature of Java program.  The classes are used to map real world problems.  MAIN METHOD CLASS:  Java stand alone program requires main method as starting point.  This is essential part of program  Main method creates object of various classes.  On reaching end of the main the program terminate and the control passes back to then operating system.  Note: Java Compiler will compile class that do not contain main() method. If main() is not declared it give runtime error, because at compile time Compiler is not using main() but interpreter use at runtime.


Download ppt "Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with."

Similar presentations


Ads by Google