Presentation is loading. Please wait.

Presentation is loading. Please wait.

Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.

Similar presentations


Presentation on theme: "Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html."— Presentation transcript:

1 Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html

2 Java is Simple: Small language, Small Interpreter(40k) and large libraries Object Oriented: Supports encapsulation,inheritance,abstraction and polymorphism. Architecture neutral: Java source files are compiled to byte codes and are interpreted by the jvm. Portable: Primitive data types and their behaviour are specified by the language Libraries define portable interfaces. Distributed: Libraries for network programming and remote method invocation. Multithreaded: Threads are easier to create and use. Secure: Sandbox model, java byte code verification. Automatic memory management :Garbage collection

3 Architecture http://www.artima.com/insidejvm/ed2/introarch.html

4 Java Virtual Machine Load class files and execute the byte codes. Class files from java api that are needed by the program are loaded into JVM. Byte codes are executed in execution engine Class Loader Execution Engine Host Operating Systema Program class files Java api class files

5 Class loader Bootstrap class loader Loads the core Java libraries[5] ( /lib directory). This class loader, which is part of the core JVM, is written in native code. Extensions class loader loads the code in the extensions directories ( /lib/ext or any other directory specified by the java.ext.dirs system property). It is implemented by the sun.misc.Launcher$ExtClassLoader class. System class loader The system class loader loads code found on java.class.path, which maps to the system CLASSPATH variable. This is implemented by the sun.misc.Launcher$AppClassLoader class.CLASSPATH User Defined class loaders By default, all user classes are loaded by the default system class loader, but it is possible to replace it by a user-defined ClassLoader.

6 Garbage collection Automatically removes unused objects from memory and thus developer need not explicitly free the memory of the objects used Benefits Avoids memory leakage Avoid memory corruption Increase productivity

7 Installation Download and install Java sdk for your Operating system Set JAVA_HOME environment variable to be the path of home directory of your java installation Add %JAVA_HOME%/bin to path environment variable in windows Type java –version in your command line will give details of your java installation.

8 Hello world package com.training; class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); // Display the message. }

9 Running the program Create a source file(.java file) A source file contains code, written in the Java programming language, that you and other programmers can understand. You can use any text editor to create and edit source files. It should be.java file and the name of the file should match the name of the public class in the file. There can be only one public class in a java source file. Compile the source file into a.class file The Java programming language compiler (javac) takes your source file and translates its text into instructions that the Java virtual machine can understand. The instructions contained within this file are known as bytecodes. Javac HelloworldApp.java This will create a HelloworldApp.class file in the package specified in the java file. Run the program The Java application launcher tool (java) uses the Java virtual machine to run your application. Java HelloworldApp HelloWorldApp, will simply display the greeting "Hello world!".

10 Data Types Integral byte short int long Textual char String Floating Point types float double Boolean Type true false

11 Arrays A fixed length structure that stores multiple values of the same type. // Creating an array of type String of length 10 String [] names =new String[10] names[0]=“Kumar”; names[1]=“Raj”; // Print array values for(int i=0;i<names.length;i++){ System.out.println(names[i]); } // multi dimentional int [][] matrix = new int[4]; matrix[0] = new int[10]; matrix[1]=new int[2-0]; System.out.println(“first element :”+matrix[0][0]);

12 Why java?  OOP simplified (compared to C/C++).  Multithreading support.  A good collection library.  Platform independence.  JVM and automatic memory management  Security with sandbox model  Comparatively good performance.

13 Hands-on Hello world program Use of PATH and CLASSPATH Create a class and add to classpath and try to use it. Create a jar and add to ext\lib and use it. Input and output through console. (Write a program to accept two numbers and to print the result) Use of different data types (Program a calculator which supports four basic operations) Using Arrays Accept names separated by space in a line and print the count. Jar creation

14 References http://download.oracle.com/javase/tutorial/tutorialLearningPaths. html http://download.oracle.com/javase/tutorial/tutorialLearningPaths. html http://wikis.sun.com/display/code/Home http://download.oracle.com/javase/tutorial/deployment/jar/index. html http://download.oracle.com/javase/tutorial/deployment/jar/index. html http://download.oracle.com/javase/tutorial/essential/environment/ paths.html http://download.oracle.com/javase/tutorial/essential/environment/ paths.html http://arhipov.blogspot.com/2011/01/java-bytecode- fundamentals.html http://arhipov.blogspot.com/2011/01/java-bytecode- fundamentals.html http://onjava.com/pub/a/onjava/2003/11/12/classloader.html http://www.artima.com/insidejvm/ed2/ http://www.youtube.com/watch?v=QMV45tHCYNI&feature=channel


Download ppt "Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html."

Similar presentations


Ads by Google