Module 01 – Introduction to Java Danairat T. Line ID: Danairat FB: Danairat Thanabodithammachari +668-1559-1446
Fundamental Java Programming The Course Outline Module 01 – Introduction to Java Module 02 – Basic Java Programming Module 03 – Control Flow and Exception Handling Module 04 – Object Oriented in Java Module 05 – Java Package and Access Control Module 06 – Java File IO Module 07 – Java Networking Module 08 – Java Threading
Module 01 – Introduction to Java • Introduction • Java History • Java Principles • Java Platform • HotSpot JVM • Writing a First Java Program • Coding Convention
Specific Application Development Knowledge Application Development Knowledge Foundation Programming Knowledge Fundamental Java Programming (Control Flow, OO, Java Network) Java EE and Dev. Frameworks (Containers, Spring, Hibernate, ADF, etc.) SOA, ESB, CEP, BPEL, BPM, ECM Portal, RIA, SSO, IdM Development Lifecycle - Project Mgmt. - Release Mgmt. - Req. Mgmt. (Roles, Event) - Design. Build - Fn & Non-Fn Test - Migrate, Deploy, Monitor - Support Java Developer Trainings
Java History Originally, Java developed by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture.
Java History JDK 1.0 (1995) — First Java Released. JDK 1.1 (February 19, 1997) — Major additions included an extensive retooling of the AWT event model, inner classes added to the language, JavaBeans and JDBC. J2SE 1.2 (December 8, 1998) — Codename Playground. This replaced JDK to distinguish the base platform from J2EE (Java 2 Platform, Enterprise Edition) and J2ME (Java 2 Platform, Micro Edition). Major additions included reflection, a Collections framework, Java IDL (an IDL implementation for CORBA interoperability), and the integration of the Swing graphical API into the core classes. J2SE 1.3 (May 8, 2000) — Codename Kestrel. Notable changes included the bundling of the HotSpot JVM (the HotSpot JVM was first released in April, 1999 for the J2SE 1.2 JVM), JavaSound, Java Naming and Directory Interface (JNDI) and Java Platform Debugger Architecture (JPDA).
Java History J2SE 1.4 (February 6, 2002) — Codename Merlin. This was the first release of the Java platform developed under the Java Community Process as JSR 59. Major changes included regular expressions modeled after Perl, exception chaining, an integrated XML parser and XSLT processor (JAXP), and Java Web Start. J2SE 5.0 (September 30, 2004) — Codename Tiger. Originally numbered 1.5, which is still used as the internal version number. Developed under JSR 176, Tiger added a number of significant new language features including the for-each loop, generics, autoboxing and var-args.
Java History Java SE 6 (December 11, 2006) — Codename Mustang — The current version is bundled with a database manager, facilitates the use of scripting languages (currently JavaScript using Mozilla's Rhino engine). As of this version, Sun replaced the name "J2SE" with Java SE and dropped the ".0" from the version number. Other major changes include support for pluggable annotations (JSR 269), lots of GUI improvements, including native UI enhancements to support the look and feel of Windows Vista, and improvements to the Java Platform Debugger Architecture (JPDA) & JVM Tool Interface for better monitoring and troubleshooting Java SE 7 — Codename Dolphin. The Dolphin Project started in August 2006, with release estimated in 2011. New builds including enhancements and bug fixes are released approximately weekly. In addition to the language changes, much more dramatic changes have been made to the Java class library over the years, which has grown from a few hundred classes in JDK 1.0 to over three thousand in J2SE 5.0. Many of the original JDK 1.0 classes and methods have been deprecated.
Java Principles There were five primary goals in the creation of the Java language: 1. It should be "simple, object oriented and familiar". 2. It should be "robust and secure". 3. It should be "architecture-neutral and portable". 4. It should execute with "high performance". 5. It should be "interpreted, threaded, and dynamic".
Java Platform Java SE (Standard Edition): For general-purpose use on desktop PCs, servers and similar devices. Java EE (Enterprise Edition): Java SE plus various APIs useful for multi-tier client–server enterprise applications. Java ME (Micro Edition): Specifies several different sets of libraries (known as profiles) for devices that are sufficiently limited that supplying the full set of Java libraries would take up unacceptably large amounts of storage. it is not used on any of today's newest mobile platforms (e.g. iPhone, Android, Windows Phone 7, MeeGo, BlackBerry's new QNX). Java Card: A technology that allows small Java-based applications (applets) to be run securely on smart cards and similar small-memory-footprint devices.
Java FX A software platform for creating and delivering rich Internet applications that can run across a wide variety of connected devices to build applications for desktop, browser and mobile phones. TV set-top boxes, gaming consoles, Blu-ray players and other platforms are planned. To build JavaFX apps developers use a statically typed, declarative language called JavaFX Script; Java code can be integrated into JavaFX programs. JavaFX is compiled to Java bytecode, so JavaFX applications run on any desktop and browser that runs the Java Runtime Environment (JRE) and on top of mobile phones running Java ME. JavaFX may compete on the desktop with Adobe AIR, Apache Pivot, OpenLaszlo and Microsoft Silverlight.
HotSpot JVM providing Java runtime facilities, such as thread and object synchronization, on a variety of operating systems and architectures. It includes dynamic compilers that adaptively compile Java bytecodes into optimized machine instructions and efficiently manages the Java heap using garbage collectors,
HotSpot JVM Options Option and Default Value Description -XX:-AllowUserSignalHandlers Do not complain if the application installs signal handlers. (Relevant to Solaris and Linux only.) -XX:AltStackSize=16384 Alternate signal stack size (in Kbytes). (Relevant to Solaris only, removed from 5.0.) -XX:-DisableExplicitGC Disable calls to System.gc(), JVM still performs garbage collection when necessary. -XX:+FailOverToOldVerifier Fail over to old verifier when the new type checker fails. (Introduced in 6.) -XX:+HandlePromotionFailure The youngest generation collection does not require a guarantee of full promotion of all live objects. (Introduced in 1.4.2 update 11) [5.0 and earlier: false.] -XX:+MaxFDLimit Bump the number of file descriptors to max. (Relevant to Solaris only.) -XX:PreBlockSpin=10 Spin count variable for use with -XX:+UseSpinning. Controls the maximum spin iterations allowed before entering operating system thread synchronization code. (Introduced in 1.4.2.) -XX:-RelaxAccessControlCheck Relax the access control checks in the verifier. (Introduced in 6.) -XX:+ScavengeBeforeFullGC Do young generation GC prior to a full GC. (Introduced in 1.4.1.) -XX:+UseAltSigs Use alternate signals instead of SIGUSR1 and SIGUSR2 for VM internal signals. (Introduced in 1.3.1 update 9, 1.4.1. Relevant to Solaris only.) -XX:+UseBoundThreads Bind user level threads to kernel threads. (Relevant to Solaris only.) -XX:-UseConcMarkSweepGC Use concurrent mark-sweep collection for the old generation. (Introduced in 1.4.1) -XX:+UseGCOverheadLimit Use a policy that limits the proportion of the VM's time that is spent in GC before an OutOfMemory error is thrown. (Introduced in 6.) -XX:+UseLWPSynchronization Use LWP-based instead of thread based synchronization. (Introduced in 1.4.0. Relevant to Solaris only.) -XX:-UseParallelGC Use parallel garbage collection for scavenges. (Introduced in 1.4.1) -XX:-UseParallelOldGC Use parallel garbage collection for the full collections. Enabling this option automatically sets -XX:+UseParallelGC. (Introduced in 5.0 update 6.) -XX:-UseSerialGC Use serial garbage collection. (Introduced in 5.0.) -XX:-UseSpinning Enable naive spinning on Java monitor before entering operating system thread synchronizaton code. (Relevant to 1.4.2 and 5.0 only.) [1.4.2, multi-processor Windows platforms: true] -XX:+UseTLAB Use thread-local object allocation (Introduced in 1.4.0, known as UseTLE prior to that.) [1.4.2 and earlier, x86 or with -client: false] -XX:+UseSplitVerifier Use the new type checker with StackMapTable attributes. (Introduced in 5.0.)[5.0: false] -XX:+UseThreadPriorities Use native thread priorities. -XX:+UseVMInterruptibleIO Thread interrupt before or with EINTR for I/O operations results in OS_INTRPT. (Introduced in 6. Relevant to Solaris only.) Behavioral Options Option and Default Value Description -XX:+AggressiveOpts Turn on point performance compiler optimizations that are expected to be default in upcoming releases. (Introduced in 5.0 update 6.) -XX:CompileThreshold=10000 Number of method invocations/branches before compiling [-client: 1,500] -XX:LargePageSizeInBytes=4m Sets the large page size used for the Java heap. (Introduced in 1.4.0 update 1.) [amd64: 2m.] -XX:MaxHeapFreeRatio=70 Maximum percentage of heap free after GC to avoid shrinking. -XX:MaxNewSize=size Maximum size of new generation (in bytes). Since 1.4, MaxNewSize is computed as a function of NewRatio. [1.3.1 Sparc: 32m; 1.3.1 x86: 2.5m.] -XX:MaxPermSize=64m Size of the Permanent Generation. [5.0 and newer: 64 bit VMs are scaled 30% larger; 1.4 amd64: 96m; 1.3.1 -client: 32m.] -XX:MinHeapFreeRatio=40 Minimum percentage of heap free after GC to avoid expansion. -XX:NewRatio=2 Ratio of new/oldgeneration sizes. [Sparc -client: 8; x86 -server: 8; x86 -client: 12.]-client: 4 (1.3) 8 (1.3.1+), x86: 12] -XX:NewSize=2.125m Default size of new generation (in bytes) [5.0 and newer: 64 bit VMs are scaled 30% larger; x86: 1m; x86, 5.0 and older: 640k] -XX:ReservedCodeCacheSize=32m Reserved code cache size (in bytes) - maximum code cache size. [Solaris 64-bit, amd64, and -server x86: 48m; in 1.5.0_06 and earlier, Solaris 64-bit and and64: 1024m.] -XX:SurvivorRatio=8 Ratio of eden/survivor space size [Solaris amd64: 6; Sparc in 1.3.1: 25; other Solaris platforms in 5.0 and earlier: 32] -XX:TargetSurvivorRatio=50 Desired percentage of survivor space used after scavenge. -XX:ThreadStackSize=512 Thread Stack Size (in Kbytes). (0 means use default stack size) [Sparc: 512; Solaris x86: 320 (was 256 prior in 5.0 and earlier); Sparc 64 bit: 1024; Linux amd64: 1024 (was 0 in 5.0 and earlier); all others 0.] -XX:+UseBiasedLocking Enable biased locking. For more details, see this tuning example. (Introduced in 5.0 update 6.) [5.0: false] -XX:+UseFastAccessorMethods Use optimized versionsof Get<Primitive>Field. -XX:-UseISM Use Intimate Shared Memory. [Not accepted for non-Solaris platforms.] For details, see Intimate Shared Memory. -XX:+UseLargePages Use large page memory. (Introduced in 5.0 update 5.) For details, see Java Support for Large Memory Pages. -XX:+UseMPSS Use Multiple Page Size Support w/4mb pages for the heap. Do not use with ISM as this replaces the need for ISM. (Introduced in 1.4.0 update 1, Relevant to Solaris 9 and newer.) [1.4.1 and earlier: false] -XX:+UseStringCache Enables cachingof commonlyallocated strings. -XX:AllocatePrefetchLines=1 Number of cache lines to load after the last object allocationusing prefetch instructions generated in JIT compiled code. Default values are 1 if the last allocated object was an instance and 3 if it was an array. -XX:AllocatePrefetchStyle=1 Generated code style for prefetch instructions. 0 - no prefetch instructions are generate*d*, 1 - execute prefetch instructionsafter each allocation, 2 - use TLAB allocation watermark pointer to gate when prefetch instructions are executed. -XX:+UseCompressedStrings Use a byte[] for Strings which can be represented as pure ASCII. (Introduced in Java 6 Update 21 Performance Release) -XX:+OptimizeStringConcat Optimize String concatenationoperations where possible. (Introduced in Java 6 Update 20) Performance Options Option and Default Value Description -XX:-CITime Prints time spent in JIT Compiler. (Introduced in 1.4.0.) -XX:ErrorFile=./hs_err_pid<pid>.log If an error occurs, save the error data to this file. (Introduced in 6.) -XX:-ExtendedDTraceProbes Enable performance-impacting dtrace probes. (Introduced in 6. Relevant to Solaris only.) -XX:HeapDumpPath=./java_pid<pid>.hprof Path to directory or filename for heap dump. Manageable. (Introduced in 1.4.2 update 12, 5.0 update 7.) -XX:-HeapDumpOnOutOfMemoryError Dump heap to file when java.lang.OutOfMemoryError is thrown. Manageable. (Introduced in 1.4.2 update 12, 5.0 update 7.) -XX:OnError="<cmd args>;<cmd args>" Run user-defined commands on fatal error. (Introduced in 1.4.2 update 9.) -XX:OnOutOfMemoryError="<cmd args>; <cmd args>" Run user-defined commands when an OutOfMemoryError is first thrown. (Introduced in 1.4.2 update 12, 6) -XX:-PrintClassHistogram Print a histogram of class instances on Ctrl-Break. Manageable. (Introduced in 1.4.2.) The jmap -histo command provides equivalent functionality. -XX:-PrintConcurrentLocks Print java.util.concurrent locks in Ctrl-Break thread dump. Manageable. (Introduced in 6.) The jstack -l command provides equivalent functionality. -XX:-PrintCommandLineFlags Print flags that appeared on the command line. (Introduced in 5.0.) -XX:-PrintCompilation Print message when a method is compiled. -XX:-PrintGC Print messages at garbage collection. Manageable. -XX:-PrintGCDetails Print more details at garbage collection. Manageable. (Introduced in 1.4.0.) -XX:-PrintGCTimeStamps Print timestamps at garbage collection. Manageable (Introduced in 1.4.0.) -XX:-PrintTenuringDistribution Print tenuring age information. -XX:-TraceClassLoading Trace loading of classes. -XX:-TraceClassLoadingPreorder Trace all classes loaded in order referenced (not loaded). (Introduced in 1.4.2.) -XX:-TraceClassResolution Trace constant pool resolutions. (Introduced in 1.4.2.) -XX:-TraceClassUnloading Trace unloading of classes. -XX:-TraceLoaderConstraints Trace recording of loader constraints. (Introduced in 6.) -XX:+PerfSaveDataToFile Saves jvmstat binary data on exit. -XX:ParallelGCThreads= Sets the number of garbage collection threads in the young and old parallel garbage collectors. The default value varies with the platform on which the JVM is running. -XX:+UseCompressedOops Enables the use of compressed pointers (object references represented as 32 bit offsets instead of 64-bit pointers) for optimized 64-bit performance with Java heap sizes less than 32gb. -XX:+AlwaysPreTouch Pre-touch the Java heap during JVM initialization. Every page of the heap is thus demand-zeroed during initialization rather than incrementally during application execution. -XX:AllocatePrefetchDistance= Sets the prefetch distance for object allocation. Memory about to be written with the value of new objects is prefetched into cache at this distance (in bytes) beyond the address of the last allocated object. Each Java thread has its own allocationpoint. The default value varies with the platform on which the JVM is running. -XX:InlineSmallCode= Inline a previously compiledmethod only if its generated native code size is less than this. The default value varies with the platform on which the JVM is running. -XX:MaxInlineSize=35 Maximum bytecode size of a method to be inlined. -XX:FreqInlineSize= Maximum bytecode size of a frequently executed method to be inlined. The default value varies with the platform on which the JVM is running. -XX:LoopUnrollLimit= Unroll loop bodies with server compilerintermediate representationnode count less than this value. The limit used by the server compileris a function of this value, not the actual value. The default value varies with the platform on which the JVM is running. -XX:InitialTenuringThreshold=7 Sets the initialtenuring threshold for use in adaptive GC sizing in the parallel young collector. The tenuring threshold is the number of times an object survives a young collection before being promoted to the old, or tenured, generation. -XX:MaxTenuringThreshold= Sets the maximum tenuringthreshold for use in adaptive GC sizing. The current largest value is 15. The default value is 15 for the parallelcollectorand is 4 for CMS. Debugging Options
JConsole >java/bin/jconsole Overview Memory Threads Classes VM Summary MBean
Java SE Security Overview Topic Detail Platform Security Built-in language security features enforced by the Java compiler and virtual machine: Strong data typing Automatic memory management Bytecode verification Secure class loading Cryptography Comprehensive API with support for a wide range of cryptographic services including digital signatures, message digests, ciphers (symmetric, asymmetric, stream & block), message authentication codes, key generators and key factories Support for a wide range of standard algorithms including RSA, DSA, AES, Triple DES, SHA, PKCS#5, RC2, and RC4. PKCS#11 cryptographic token support Authentication and Access Control Abstract authentication APIs that can incorporate a wide range of login mechanisms through a pluggable architecture. A comprehensive policy and permissions API that allows the developer to create and administer applications requiring fine-grained access to security-sensitive resources. Secure Communications APIs and implementations for the following standards-based secure communications protocols: Transport Layer Security (TLS), Secure Sockets Layer (SSL), Kerberos (accessible through GSS-API), and the Simple Authentication and Security Layer (SASL). Full support for HTTPS over SSL/TLS is also included. Public Key Infrastructure (PKI) Tools for managing keys and certificates and comprehensive, abstract APIs with support for the following features and algorithms: Certificates and Certificate Revocation Lists (CRLs): X.509 Certification Path Validators and Builders: PKIX (RFC 3280), On-line Certificate Status Protocol (OCSP) KeyStores: PKCS#11, PKCS#12 Certificate Stores (Repositories): LDAP, java.util.Collection
Writing a First Java Program public class Class1 { public static void main(String[] args) { System.out.println("Hello World"); } } Compile: >javac Class1.java Execute: >java Class1
Coding Convention Line Length Avoid lines longer than 80 characters, since they’re not handled well by many terminals and tools. Indentation Four spaces should be used as the unit of indentation. Wrapping Lines When an expression will not fit on a single line, break it according to these general principles: • Break after a comma. • Break before an operator. • Align the new line with the beginning of the expression at the same level on the previous line.
Coding Convention Comments Java programs can have two kinds of comments: implementation comments and documentation comments. - Implementation comments are those found in C++, which are delimited by /*...*/, and //. - Documentation comments (known as “doc comments”) are Java-only, and are delimited by /**...*/. Doc comments can be extracted to HTML files using the javadoc tool. Number Per Line One declaration per line is recommended since it encourages commenting. In other words, int level; // indentation level int size; // size of table is preferred over int level, size;
Coding Convention Placement Put declarations only at the beginning of blocks. (A block is any code surrounded by curly braces “{” and “}”.) Don’t wait to declare variables until their first use; it can confuse the unwary programmer and hamper code portability within the scope. void MyMethod() { int int1; // beginning of method block if (condition) { int int2; // beginning of "if" block ... } }
Coding Convention
LAB - Installing your Java Development Platform 01 – Install JDK 1.) Download and Install JDK ( eg. jdk-6u25-windows-i586.exe) from web site http://www.oracle.com/technetwork/java/javase/downloads/index.html
LAB - Installing your Java Development Platform 01 – Install JDK 2.) Select Install Components and Location, Click “Next”.
LAB - Installing your Java Development Platform 01 – Install JDK 3.) Wait for installation, click “Finish”
LAB - Installing your Java Development Platform 02 – Install IDE - JDeveloper 1.) Extract Jdeveloper in to a folder 2.) Execute “jdeveloper.exe” You can create the shortcut icon .
LAB - Installing your Java Development Platform 02 – Install IDE - JDeveloper 3.) Click “Browse” and select “java.exe” from previous installed JDK
LAB - Installing your Java Development Platform 02 – Install IDE - JDeveloper 4.) Click “OK”, wait until Jdeveloper loaded and see the Jdeveloper welcome screen.
Danairat T. Line ID: Danairat FB: Danairat Thanabodithammachari +668-1559-1446 Thank you

Java Programming - 01 intro to java

  • 1.
    Module 01 –Introduction to Java Danairat T. Line ID: Danairat FB: Danairat Thanabodithammachari +668-1559-1446
  • 2.
    Fundamental Java Programming TheCourse Outline Module 01 – Introduction to Java Module 02 – Basic Java Programming Module 03 – Control Flow and Exception Handling Module 04 – Object Oriented in Java Module 05 – Java Package and Access Control Module 06 – Java File IO Module 07 – Java Networking Module 08 – Java Threading
  • 3.
    Module 01 –Introduction to Java • Introduction • Java History • Java Principles • Java Platform • HotSpot JVM • Writing a First Java Program • Coding Convention
  • 4.
    Specific Application Development Knowledge Application Development Knowledge Foundation Programming Knowledge Fundamental Java Programming (Control Flow,OO, Java Network) Java EE and Dev. Frameworks (Containers, Spring, Hibernate, ADF, etc.) SOA, ESB, CEP, BPEL, BPM, ECM Portal, RIA, SSO, IdM Development Lifecycle - Project Mgmt. - Release Mgmt. - Req. Mgmt. (Roles, Event) - Design. Build - Fn & Non-Fn Test - Migrate, Deploy, Monitor - Support Java Developer Trainings
  • 5.
    Java History Originally, Javadeveloped by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture.
  • 6.
    Java History JDK 1.0(1995) — First Java Released. JDK 1.1 (February 19, 1997) — Major additions included an extensive retooling of the AWT event model, inner classes added to the language, JavaBeans and JDBC. J2SE 1.2 (December 8, 1998) — Codename Playground. This replaced JDK to distinguish the base platform from J2EE (Java 2 Platform, Enterprise Edition) and J2ME (Java 2 Platform, Micro Edition). Major additions included reflection, a Collections framework, Java IDL (an IDL implementation for CORBA interoperability), and the integration of the Swing graphical API into the core classes. J2SE 1.3 (May 8, 2000) — Codename Kestrel. Notable changes included the bundling of the HotSpot JVM (the HotSpot JVM was first released in April, 1999 for the J2SE 1.2 JVM), JavaSound, Java Naming and Directory Interface (JNDI) and Java Platform Debugger Architecture (JPDA).
  • 7.
    Java History J2SE 1.4(February 6, 2002) — Codename Merlin. This was the first release of the Java platform developed under the Java Community Process as JSR 59. Major changes included regular expressions modeled after Perl, exception chaining, an integrated XML parser and XSLT processor (JAXP), and Java Web Start. J2SE 5.0 (September 30, 2004) — Codename Tiger. Originally numbered 1.5, which is still used as the internal version number. Developed under JSR 176, Tiger added a number of significant new language features including the for-each loop, generics, autoboxing and var-args.
  • 8.
    Java History Java SE6 (December 11, 2006) — Codename Mustang — The current version is bundled with a database manager, facilitates the use of scripting languages (currently JavaScript using Mozilla's Rhino engine). As of this version, Sun replaced the name "J2SE" with Java SE and dropped the ".0" from the version number. Other major changes include support for pluggable annotations (JSR 269), lots of GUI improvements, including native UI enhancements to support the look and feel of Windows Vista, and improvements to the Java Platform Debugger Architecture (JPDA) & JVM Tool Interface for better monitoring and troubleshooting Java SE 7 — Codename Dolphin. The Dolphin Project started in August 2006, with release estimated in 2011. New builds including enhancements and bug fixes are released approximately weekly. In addition to the language changes, much more dramatic changes have been made to the Java class library over the years, which has grown from a few hundred classes in JDK 1.0 to over three thousand in J2SE 5.0. Many of the original JDK 1.0 classes and methods have been deprecated.
  • 9.
    Java Principles There werefive primary goals in the creation of the Java language: 1. It should be "simple, object oriented and familiar". 2. It should be "robust and secure". 3. It should be "architecture-neutral and portable". 4. It should execute with "high performance". 5. It should be "interpreted, threaded, and dynamic".
  • 10.
    Java Platform Java SE(Standard Edition): For general-purpose use on desktop PCs, servers and similar devices. Java EE (Enterprise Edition): Java SE plus various APIs useful for multi-tier client–server enterprise applications. Java ME (Micro Edition): Specifies several different sets of libraries (known as profiles) for devices that are sufficiently limited that supplying the full set of Java libraries would take up unacceptably large amounts of storage. it is not used on any of today's newest mobile platforms (e.g. iPhone, Android, Windows Phone 7, MeeGo, BlackBerry's new QNX). Java Card: A technology that allows small Java-based applications (applets) to be run securely on smart cards and similar small-memory-footprint devices.
  • 11.
    Java FX A softwareplatform for creating and delivering rich Internet applications that can run across a wide variety of connected devices to build applications for desktop, browser and mobile phones. TV set-top boxes, gaming consoles, Blu-ray players and other platforms are planned. To build JavaFX apps developers use a statically typed, declarative language called JavaFX Script; Java code can be integrated into JavaFX programs. JavaFX is compiled to Java bytecode, so JavaFX applications run on any desktop and browser that runs the Java Runtime Environment (JRE) and on top of mobile phones running Java ME. JavaFX may compete on the desktop with Adobe AIR, Apache Pivot, OpenLaszlo and Microsoft Silverlight.
  • 12.
    HotSpot JVM providing Javaruntime facilities, such as thread and object synchronization, on a variety of operating systems and architectures. It includes dynamic compilers that adaptively compile Java bytecodes into optimized machine instructions and efficiently manages the Java heap using garbage collectors,
  • 13.
    HotSpot JVM Options Optionand Default Value Description -XX:-AllowUserSignalHandlers Do not complain if the application installs signal handlers. (Relevant to Solaris and Linux only.) -XX:AltStackSize=16384 Alternate signal stack size (in Kbytes). (Relevant to Solaris only, removed from 5.0.) -XX:-DisableExplicitGC Disable calls to System.gc(), JVM still performs garbage collection when necessary. -XX:+FailOverToOldVerifier Fail over to old verifier when the new type checker fails. (Introduced in 6.) -XX:+HandlePromotionFailure The youngest generation collection does not require a guarantee of full promotion of all live objects. (Introduced in 1.4.2 update 11) [5.0 and earlier: false.] -XX:+MaxFDLimit Bump the number of file descriptors to max. (Relevant to Solaris only.) -XX:PreBlockSpin=10 Spin count variable for use with -XX:+UseSpinning. Controls the maximum spin iterations allowed before entering operating system thread synchronization code. (Introduced in 1.4.2.) -XX:-RelaxAccessControlCheck Relax the access control checks in the verifier. (Introduced in 6.) -XX:+ScavengeBeforeFullGC Do young generation GC prior to a full GC. (Introduced in 1.4.1.) -XX:+UseAltSigs Use alternate signals instead of SIGUSR1 and SIGUSR2 for VM internal signals. (Introduced in 1.3.1 update 9, 1.4.1. Relevant to Solaris only.) -XX:+UseBoundThreads Bind user level threads to kernel threads. (Relevant to Solaris only.) -XX:-UseConcMarkSweepGC Use concurrent mark-sweep collection for the old generation. (Introduced in 1.4.1) -XX:+UseGCOverheadLimit Use a policy that limits the proportion of the VM's time that is spent in GC before an OutOfMemory error is thrown. (Introduced in 6.) -XX:+UseLWPSynchronization Use LWP-based instead of thread based synchronization. (Introduced in 1.4.0. Relevant to Solaris only.) -XX:-UseParallelGC Use parallel garbage collection for scavenges. (Introduced in 1.4.1) -XX:-UseParallelOldGC Use parallel garbage collection for the full collections. Enabling this option automatically sets -XX:+UseParallelGC. (Introduced in 5.0 update 6.) -XX:-UseSerialGC Use serial garbage collection. (Introduced in 5.0.) -XX:-UseSpinning Enable naive spinning on Java monitor before entering operating system thread synchronizaton code. (Relevant to 1.4.2 and 5.0 only.) [1.4.2, multi-processor Windows platforms: true] -XX:+UseTLAB Use thread-local object allocation (Introduced in 1.4.0, known as UseTLE prior to that.) [1.4.2 and earlier, x86 or with -client: false] -XX:+UseSplitVerifier Use the new type checker with StackMapTable attributes. (Introduced in 5.0.)[5.0: false] -XX:+UseThreadPriorities Use native thread priorities. -XX:+UseVMInterruptibleIO Thread interrupt before or with EINTR for I/O operations results in OS_INTRPT. (Introduced in 6. Relevant to Solaris only.) Behavioral Options Option and Default Value Description -XX:+AggressiveOpts Turn on point performance compiler optimizations that are expected to be default in upcoming releases. (Introduced in 5.0 update 6.) -XX:CompileThreshold=10000 Number of method invocations/branches before compiling [-client: 1,500] -XX:LargePageSizeInBytes=4m Sets the large page size used for the Java heap. (Introduced in 1.4.0 update 1.) [amd64: 2m.] -XX:MaxHeapFreeRatio=70 Maximum percentage of heap free after GC to avoid shrinking. -XX:MaxNewSize=size Maximum size of new generation (in bytes). Since 1.4, MaxNewSize is computed as a function of NewRatio. [1.3.1 Sparc: 32m; 1.3.1 x86: 2.5m.] -XX:MaxPermSize=64m Size of the Permanent Generation. [5.0 and newer: 64 bit VMs are scaled 30% larger; 1.4 amd64: 96m; 1.3.1 -client: 32m.] -XX:MinHeapFreeRatio=40 Minimum percentage of heap free after GC to avoid expansion. -XX:NewRatio=2 Ratio of new/oldgeneration sizes. [Sparc -client: 8; x86 -server: 8; x86 -client: 12.]-client: 4 (1.3) 8 (1.3.1+), x86: 12] -XX:NewSize=2.125m Default size of new generation (in bytes) [5.0 and newer: 64 bit VMs are scaled 30% larger; x86: 1m; x86, 5.0 and older: 640k] -XX:ReservedCodeCacheSize=32m Reserved code cache size (in bytes) - maximum code cache size. [Solaris 64-bit, amd64, and -server x86: 48m; in 1.5.0_06 and earlier, Solaris 64-bit and and64: 1024m.] -XX:SurvivorRatio=8 Ratio of eden/survivor space size [Solaris amd64: 6; Sparc in 1.3.1: 25; other Solaris platforms in 5.0 and earlier: 32] -XX:TargetSurvivorRatio=50 Desired percentage of survivor space used after scavenge. -XX:ThreadStackSize=512 Thread Stack Size (in Kbytes). (0 means use default stack size) [Sparc: 512; Solaris x86: 320 (was 256 prior in 5.0 and earlier); Sparc 64 bit: 1024; Linux amd64: 1024 (was 0 in 5.0 and earlier); all others 0.] -XX:+UseBiasedLocking Enable biased locking. For more details, see this tuning example. (Introduced in 5.0 update 6.) [5.0: false] -XX:+UseFastAccessorMethods Use optimized versionsof Get<Primitive>Field. -XX:-UseISM Use Intimate Shared Memory. [Not accepted for non-Solaris platforms.] For details, see Intimate Shared Memory. -XX:+UseLargePages Use large page memory. (Introduced in 5.0 update 5.) For details, see Java Support for Large Memory Pages. -XX:+UseMPSS Use Multiple Page Size Support w/4mb pages for the heap. Do not use with ISM as this replaces the need for ISM. (Introduced in 1.4.0 update 1, Relevant to Solaris 9 and newer.) [1.4.1 and earlier: false] -XX:+UseStringCache Enables cachingof commonlyallocated strings. -XX:AllocatePrefetchLines=1 Number of cache lines to load after the last object allocationusing prefetch instructions generated in JIT compiled code. Default values are 1 if the last allocated object was an instance and 3 if it was an array. -XX:AllocatePrefetchStyle=1 Generated code style for prefetch instructions. 0 - no prefetch instructions are generate*d*, 1 - execute prefetch instructionsafter each allocation, 2 - use TLAB allocation watermark pointer to gate when prefetch instructions are executed. -XX:+UseCompressedStrings Use a byte[] for Strings which can be represented as pure ASCII. (Introduced in Java 6 Update 21 Performance Release) -XX:+OptimizeStringConcat Optimize String concatenationoperations where possible. (Introduced in Java 6 Update 20) Performance Options Option and Default Value Description -XX:-CITime Prints time spent in JIT Compiler. (Introduced in 1.4.0.) -XX:ErrorFile=./hs_err_pid<pid>.log If an error occurs, save the error data to this file. (Introduced in 6.) -XX:-ExtendedDTraceProbes Enable performance-impacting dtrace probes. (Introduced in 6. Relevant to Solaris only.) -XX:HeapDumpPath=./java_pid<pid>.hprof Path to directory or filename for heap dump. Manageable. (Introduced in 1.4.2 update 12, 5.0 update 7.) -XX:-HeapDumpOnOutOfMemoryError Dump heap to file when java.lang.OutOfMemoryError is thrown. Manageable. (Introduced in 1.4.2 update 12, 5.0 update 7.) -XX:OnError="<cmd args>;<cmd args>" Run user-defined commands on fatal error. (Introduced in 1.4.2 update 9.) -XX:OnOutOfMemoryError="<cmd args>; <cmd args>" Run user-defined commands when an OutOfMemoryError is first thrown. (Introduced in 1.4.2 update 12, 6) -XX:-PrintClassHistogram Print a histogram of class instances on Ctrl-Break. Manageable. (Introduced in 1.4.2.) The jmap -histo command provides equivalent functionality. -XX:-PrintConcurrentLocks Print java.util.concurrent locks in Ctrl-Break thread dump. Manageable. (Introduced in 6.) The jstack -l command provides equivalent functionality. -XX:-PrintCommandLineFlags Print flags that appeared on the command line. (Introduced in 5.0.) -XX:-PrintCompilation Print message when a method is compiled. -XX:-PrintGC Print messages at garbage collection. Manageable. -XX:-PrintGCDetails Print more details at garbage collection. Manageable. (Introduced in 1.4.0.) -XX:-PrintGCTimeStamps Print timestamps at garbage collection. Manageable (Introduced in 1.4.0.) -XX:-PrintTenuringDistribution Print tenuring age information. -XX:-TraceClassLoading Trace loading of classes. -XX:-TraceClassLoadingPreorder Trace all classes loaded in order referenced (not loaded). (Introduced in 1.4.2.) -XX:-TraceClassResolution Trace constant pool resolutions. (Introduced in 1.4.2.) -XX:-TraceClassUnloading Trace unloading of classes. -XX:-TraceLoaderConstraints Trace recording of loader constraints. (Introduced in 6.) -XX:+PerfSaveDataToFile Saves jvmstat binary data on exit. -XX:ParallelGCThreads= Sets the number of garbage collection threads in the young and old parallel garbage collectors. The default value varies with the platform on which the JVM is running. -XX:+UseCompressedOops Enables the use of compressed pointers (object references represented as 32 bit offsets instead of 64-bit pointers) for optimized 64-bit performance with Java heap sizes less than 32gb. -XX:+AlwaysPreTouch Pre-touch the Java heap during JVM initialization. Every page of the heap is thus demand-zeroed during initialization rather than incrementally during application execution. -XX:AllocatePrefetchDistance= Sets the prefetch distance for object allocation. Memory about to be written with the value of new objects is prefetched into cache at this distance (in bytes) beyond the address of the last allocated object. Each Java thread has its own allocationpoint. The default value varies with the platform on which the JVM is running. -XX:InlineSmallCode= Inline a previously compiledmethod only if its generated native code size is less than this. The default value varies with the platform on which the JVM is running. -XX:MaxInlineSize=35 Maximum bytecode size of a method to be inlined. -XX:FreqInlineSize= Maximum bytecode size of a frequently executed method to be inlined. The default value varies with the platform on which the JVM is running. -XX:LoopUnrollLimit= Unroll loop bodies with server compilerintermediate representationnode count less than this value. The limit used by the server compileris a function of this value, not the actual value. The default value varies with the platform on which the JVM is running. -XX:InitialTenuringThreshold=7 Sets the initialtenuring threshold for use in adaptive GC sizing in the parallel young collector. The tenuring threshold is the number of times an object survives a young collection before being promoted to the old, or tenured, generation. -XX:MaxTenuringThreshold= Sets the maximum tenuringthreshold for use in adaptive GC sizing. The current largest value is 15. The default value is 15 for the parallelcollectorand is 4 for CMS. Debugging Options
  • 14.
    JConsole >java/bin/jconsole Overview MemoryThreads Classes VM Summary MBean
  • 15.
    Java SE SecurityOverview Topic Detail Platform Security Built-in language security features enforced by the Java compiler and virtual machine: Strong data typing Automatic memory management Bytecode verification Secure class loading Cryptography Comprehensive API with support for a wide range of cryptographic services including digital signatures, message digests, ciphers (symmetric, asymmetric, stream & block), message authentication codes, key generators and key factories Support for a wide range of standard algorithms including RSA, DSA, AES, Triple DES, SHA, PKCS#5, RC2, and RC4. PKCS#11 cryptographic token support Authentication and Access Control Abstract authentication APIs that can incorporate a wide range of login mechanisms through a pluggable architecture. A comprehensive policy and permissions API that allows the developer to create and administer applications requiring fine-grained access to security-sensitive resources. Secure Communications APIs and implementations for the following standards-based secure communications protocols: Transport Layer Security (TLS), Secure Sockets Layer (SSL), Kerberos (accessible through GSS-API), and the Simple Authentication and Security Layer (SASL). Full support for HTTPS over SSL/TLS is also included. Public Key Infrastructure (PKI) Tools for managing keys and certificates and comprehensive, abstract APIs with support for the following features and algorithms: Certificates and Certificate Revocation Lists (CRLs): X.509 Certification Path Validators and Builders: PKIX (RFC 3280), On-line Certificate Status Protocol (OCSP) KeyStores: PKCS#11, PKCS#12 Certificate Stores (Repositories): LDAP, java.util.Collection
  • 16.
    Writing a FirstJava Program public class Class1 { public static void main(String[] args) { System.out.println("Hello World"); } } Compile: >javac Class1.java Execute: >java Class1
  • 17.
    Coding Convention Line Length Avoidlines longer than 80 characters, since they’re not handled well by many terminals and tools. Indentation Four spaces should be used as the unit of indentation. Wrapping Lines When an expression will not fit on a single line, break it according to these general principles: • Break after a comma. • Break before an operator. • Align the new line with the beginning of the expression at the same level on the previous line.
  • 18.
    Coding Convention Comments Java programscan have two kinds of comments: implementation comments and documentation comments. - Implementation comments are those found in C++, which are delimited by /*...*/, and //. - Documentation comments (known as “doc comments”) are Java-only, and are delimited by /**...*/. Doc comments can be extracted to HTML files using the javadoc tool. Number Per Line One declaration per line is recommended since it encourages commenting. In other words, int level; // indentation level int size; // size of table is preferred over int level, size;
  • 19.
    Coding Convention Placement Put declarationsonly at the beginning of blocks. (A block is any code surrounded by curly braces “{” and “}”.) Don’t wait to declare variables until their first use; it can confuse the unwary programmer and hamper code portability within the scope. void MyMethod() { int int1; // beginning of method block if (condition) { int int2; // beginning of "if" block ... } }
  • 20.
  • 21.
    LAB - Installingyour Java Development Platform 01 – Install JDK 1.) Download and Install JDK ( eg. jdk-6u25-windows-i586.exe) from web site http://www.oracle.com/technetwork/java/javase/downloads/index.html
  • 22.
    LAB - Installingyour Java Development Platform 01 – Install JDK 2.) Select Install Components and Location, Click “Next”.
  • 23.
    LAB - Installingyour Java Development Platform 01 – Install JDK 3.) Wait for installation, click “Finish”
  • 24.
    LAB - Installingyour Java Development Platform 02 – Install IDE - JDeveloper 1.) Extract Jdeveloper in to a folder 2.) Execute “jdeveloper.exe” You can create the shortcut icon .
  • 25.
    LAB - Installingyour Java Development Platform 02 – Install IDE - JDeveloper 3.) Click “Browse” and select “java.exe” from previous installed JDK
  • 26.
    LAB - Installingyour Java Development Platform 02 – Install IDE - JDeveloper 4.) Click “OK”, wait until Jdeveloper loaded and see the Jdeveloper welcome screen.
  • 27.
    Danairat T. Line ID:Danairat FB: Danairat Thanabodithammachari +668-1559-1446 Thank you