1 / 28

Intro to Java Programming

Intro to Java Programming. International Technology University. Contents. Java Introduction Java Features How Java Differs from other OO languages Java and the World Wide Web Java Environment Build your first Java Program. Java Introduction.

sanura
Download Presentation

Intro to Java Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Intro to Java Programming International Technology University

  2. Contents • Java Introduction • Java Features • How Java Differs from other OO languages • Java and the World Wide Web • Java Environment • Build your first Java Program

  3. Java Introduction • Originally created for consumer electronics (TV, VCR, Freeze, Washing Machine, Mobile Phone). • Java - CPU Independent language • Internet and Web was just emerging, so Sun turned it into a language of Internet Programming. • It allows you to publish a webpage with Java code in it.

  4. Sun white paper defines Java as: • Simple and Powerful • Safe • Object Oriented • Robust • Architecture Neutral and Portable • Interpreted and High Performance • Threaded • Dynamic

  5. Java is Compiled and Interpreted Programmer Hardware and Operating System Source Code Byte Code Text Editor Compiler Interpreter .java file .class file javac Java Netscape Internet Explorer

  6. Compiled Languages Programmer Object Code Executable Code Source Code Text Editor Compiler linker .c file .o file a.out file gcc

  7. Total Platform Independence JAVA COMPILER (translator) JAVA BYTE CODE (same for all platforms) JAVA INTERPRETER (one for each different system) Windows XP Macintosh Solaris Windows NT

  8. Architecture Neutral & Portable • Java Compiler - Java source code (file with extension .java) to bytecode (file with extension .class) • Bytecode - an intermediate form, closer to machine representation • A interpreter (virtual machine) on any target platform interprets the bytecode.

  9. Architecture Neutral & Portable • Porting the java system to any new platform involves writing an interpreter. • The interpreter will figure out what the equivalent machine dependent code to run

  10. Class Environment • Core Classes language Utilities Input/Output Low-Level Networking Abstract Graphical User Interface • Internet Classes TCP/IP Networking WWW and HTML Distributed Programs

  11. Overlap of C, C++, and Java C++ C Java

  12. Java better than C++ ? • No Typedefs, Defines, or Preprocessor • No Global Variables • No Goto statements • No Pointers • No Unsafe Structures • No Multiple Inheritance • No Operator Overloading • No Automatic Coercions • No Fragile Data Types

  13. Java Applications • We can develop two types of Java programs: • Stand-alone applications • Web applications (applets)

  14. Applications vs. Applets • Different ways to run a Java executable are: Application- A stand-alone program that can be invoked from command line. A program that has a “main” method Applet- A program embedded in a web page, to be run when the page is browsed. A program that contains no “main” method

  15. Applets vs. Applications • Application –Executed by the Java interpreter. • Applet- Java enabled web browser.

  16. Execution of Applets 2 5 1 3 4 Accessing from itu.edu APPLET Development “hello.java” AT SUN.COM The browser creates a new window and a new thread and then runs the code hello.class AT SUN’S WEB SERVER Create Applet tag in HTML document Hello Java <app= “Hello”> The Internet Hello

  17. Power of Java and the Web • Deliver applications, not just information • Eliminate porting • Eliminate end-user installation • Slash software distribution costs • Reach millions of customers - instantly

  18. Java Development Kit • javac - The Java Compiler • java - The Java Interpreter • jdb- The Java Debugger • appletviewer -Tool to run the applets • javap - to print the Java bytecodes • javaprof - Java profiler • javadoc - documentation generator

  19. Let us Try Out Building your first Java Program

  20. Hello World // hello.java: Hello World program class HelloWorld { public static void main(String args[]) { System.out.println(“Hello World”); } }

  21. Program Processing • Compilation # javac hello.java results in HelloWorld.class • Execution # java HelloWorld Hello World #

  22. Simple Java Applet //HelloWorld.java import java.applet.Applet; import java.awt.*; public class HelloWorld extends Applet { public void paint(Graphics g) { g.drawString (“Hello World !”,25, 25); } }

  23. Calling an Applet <HTML> <TITLE>HELLO WORLD APPLET</TITLE> <HEAD>THE HELLO WORLD APPLET</HEAD> <APPLET CODE=“HelloWorld.class” width=500 height=500> </APPLET> </HTML>

  24. Applet Execution Using AppletViewer Using Browser

  25. Servlets JSPs EJB JDBC Java on the Web: J2EE • Thin clients • Java all “server side” Client Server

  26. Windows Users - Install • Install JDK 5 (SE), Update 12 • Set the Path to include the JDK • Start->Settings->Control Panel->System->Advanced Tab->Environmental Variables • Alter the ‘Path’ variable so that it also contains the path to the Java executable. For example: ;c:\Program Files\Java\jdk1.5.0_12 • Reboot the computer • Install Java EE SDK 5, Update 3

  27. Mac Users - Install • The Java JDK is already installed • Install JBoss – EJB Application Server • Install Ant – Build Tool (if not installed already) Mac instructions for both apps can be found at: http://developer.apple.com/internet/java/enterprisejava.html

  28. Both Mac and XP • Choose and install a Free IDE • Eclipse (http://www.eclipse.org/downloads/)

More Related