Core Java Chapter 1
Presented by, Soe Min Htut
Content
Chapter 1 Hello Java Chapter 2 Java Fundamental Chapter 3 Java OOP Chapter 4 GUI (AWT & SWING) Chapter 5 Generic and Data Collection Chapter 6 Java Input and Output (IO) Chapter 7 Java Thread Chapter 8 Java & Database (mysql)
Chapter (1) Hello Java
Java
Pogramming language originally developed James Gosling and released in 1995
Java usage
Open-source software Write Once, Run Anywhere (Windows, Mac Os, Solaris, Linux, other) Object model, platform independent, architecture neutral, simple, secure, portable, robust, multithreaded, distributed, dynamic
Chapter (1) Hello Java
Java architecture
Chapter (1) Hello Java
JRE, JDK and JVM Java Runtime Environment (JRE): minimum requirement to run java Java Development Kit (JDK): provides all requires to compile and execute java for developers Java Virtual Machine (JVM): is created when it downloads and runs JRE or JDK Windows system requirements for JDK and JRE Pentium 2.266 MHz processor, memory 128 MB, disk space 94 MB (JRE) and 180 MB (JDK) Software requirements for our learning JDK, Mysql, Netbeans and Notepad++
Chapter (1) Hello Java
Configuration JDK to run java from command prompt
Uninstall older version of JDK/JRE: Control Panel Un-install programs Java SE Development Kit and Java SE Runtime Go to Java SE download @ http://www.oracle.com/technetwork/java/javase/downloads/index.html. Click the Download button under JDK of Java SE 7 Choose your OS e.g: Windows x86 (32-bit) or Windows x64 (64-bit) By default, JDK will be installed into directory: C:\Program Files\java\Jdk1.7.0 Control Panel System Advanced system settings Advanced tab Environment Variables In System Variables box, scroll down to select PATH Edit In Variable value field, insert c:\Program Files\java\jdk1.7.0\bin followed by a semicolon (;) C:\> java version, C:\> javac
Chapter (1) Hello Java
First hello java program
Java source file extension: FirstJava.java class FirstJava { public static void main (String[] args) { System.out.println("Hello Java"); } } C:\> javac FirstJava.java Java compiled sources (bytecode): C:\> java FirstJava FirstJava.class
Chapter (1) Hello Java
Java class
Java class can be called as java program
Java code block (braces)
It defines by curly brackets { }
Java main method
Methods describe the capabilities of the class. Every method must be called from another method. The only exception is main(), which is called by the OS. Methods can accept parameters. public static void main (String args[]) { }
Java is case sensitive
Chapter (1) Hello Java
Java dot operator:
A.B ( A => B)
B
*/
Single line comment: // Multiple lines comment: /* Three types of error
(1) compile-time error (2) run-time error (3) logical error
Chapter (1) Hello Java
Installation NetBeans
Download NetBeans IDE installer from http://netbeans.org/downloads/index.html Run the downloaded installer
Writing a java program in NetBeans
File menu New Project In Choose Project dialogue under Categories, Java choose Java Application Name and Location In Project Name, enter FirstJava
Compile & Execute
Right-click Run File