Introduction to Java Programming PDF

Document Details

RejoicingMagic8285

Uploaded by RejoicingMagic8285

Islington College

Tags

java programming java programming language computer science

Summary

This document provides an introduction to Java programming, covering various aspects like features, execution, and development tools. It explains the fundamental concepts, including how Java programs are compiled and run and some basic text editors.

Full Transcript

Week – 1 Tutorial Introduction JAVA | 2 Java (Programming Language) Java is a object oriented programming language. It was first developed by James Gosling at Sun Microsystems, which is now a part of Oracle Corporation. | 3...

Week – 1 Tutorial Introduction JAVA | 2 Java (Programming Language) Java is a object oriented programming language. It was first developed by James Gosling at Sun Microsystems, which is now a part of Oracle Corporation. | 3 Java (Programming Language) It was released in 1995 as a part of Sun Microsystems Java platform. Note: Java is an island of Indonesia where first coffee was produced (called javacoffee) | 4 Features of Java | 5 Features of Java Simple:- -syntax is based on C++ (so easier for programmers to learn it after C++). -removed many confusing and/or rarely-used features e.g., explicit pointers, operator overloading etc. -No need to remove unreferenced objects because there is Automatic Garbage Collection in java. Object-oriented:- -Object-oriented means we organize our software as a combination of different types of objects that incorporates both data and behavior. -Object-oriented programming(OOPs) is a methodology that simplify software development and maintenance by providing some rules. Basic concepts of OOPs are: 1. Object 2. Class 3. Inheritance 4. Polymorphism 5. Abstraction 6. Encapsulation | 6 Features of Java Platform Independent:- -Java code can be run on multiple platforms e.g. Windows, Linux, Sun Solaris, Mac/OS etc. -Java code is compiled by the compiler and converted into bytecode. -This bytecode is a platform-independent code because it can be run on multiple platforms i.e. Write Once and Run Anywhere(WORA). | 7 Features of Java Secured: Java is secured because: -No explicit pointer -Java Programs run inside virtual machine sandbox -Classloader: adds security by separating the package for the classes of the local file system from those that are imported from network sources. -Bytecode Verifier: checks the code fragments for illegal code that can violate access right to objects. -Security Manager: determines what resources a class can access such as reading and writing to the local disk. | 8 Features of Java Robust: -Java uses strong memory management. -There are lack of pointers that avoids security problem. -There is automatic garbage collection in java. -There is exception handling and type checking mechanism in java. Architecture-neutral: -There is no implementation dependent features e.g. size of primitive types is fixed. -In C programming, int data type occupies 2 bytes of memory for 32- bit architecture and 4 bytes of memory for 64-bit architecture. But in java, it occupies 4 bytes of memory for both 32 and 64 bit architectures. Portable: We may carry the java byte code to any platform. | 9 Features of Java High-performance: Java is faster than traditional interpretation since byte code is "close" to native code still somewhat slower than a compiled language (e.g., C++) Distributed: We can create distributed applications in java. RMI and EJB are used for creating distributed applications. We may access files by calling the methods from any machine on the internet. Multi-threaded: -A thread is like a separate program, executing concurrently. -We can write Java programs that deal with many tasks at once by defining multiple threads. -The main advantage of multi-threading is that it doesn't occupy memory for each thread. It shares a common memory area. - Threads are important for multi-media, Web applications etc. | 10 Text Editor - Notepad - Notepad++ - BlueJ - Netbeans - Eclipse | 11 2 steps to execute a JAVA program. a. 1st step is to compile the JAVA program. To compile, we use the command javac. | 12 b. 2nd step is to run the JAVA program. To run the java program, we use the command java. | 13 To perform these 2 steps we need to have JDK(Java Development Kit) installed on your machine. | 14 What is JDK? | 15 JDK Acronym for Java Development Kit JAVA DEVELOPMENT KIT Process of developing | 16 JDK A development environment used to develop Java applications. Contains JRE (Java Runtime Environment) + JVM (Java Virtual Machine) Using JDK, we can develop, create and update existing Java program as well as we can compile and run a Java Program. | 17 JDK JRE IS SUBSET OF __________? JVM is subset of __________? | 18 JRE Acronym for Java Runtime Environment JAVA Runtime Environment Process to run | 19 JRE Provides only environment to run a Java program It does not provides any development tools to develop a new Java program Using JRE, we can only run existing Java program, but we cannot develop a Java program. | 20 JVM Acronym for Java Virtual Machine JAVA Virtual Machine Something which is not real | 21 JVM Responsible to execute a Java Bytecode. Provides Interpreter + Compiler (JIT) | 22 What is a Compiler? Any idea? | 23 Compiler | 24 Interpreter Assembler | 25 Structure of JAVA program package test // package declaration public class Hello { public static void main (String [] args) // main method { System.out.println(“Hello World”); //print out } } | 26 | 27 JAVA Rule and Convention Class name and the file name should have same name. File name should be save in.java extension. (eg: Hello.java) The system must have JDK installed. Locate the C:\Program Files\Java\jdk1.7.0_07\bin in My Computer →Properties → Advanced system settings → Environment Variables → New Variable Name : Path Variable Value : C:\Program Files\Java\jdk1.7.0_07\bin | 28 Open console (command prompt). Locate to Hello.java drive or its specific folder. javac Hello.java java Hello | 29 Any Questions?? | 30

Use Quizgecko on...
Browser
Browser