1 / 12

Understanding Java Programming Basics

Learn about the two types of Java programs - Application and Applet, and why Java is a cross-platform language that offers enhanced security. Discover the Java compiler, JVM, and the program development process.

lmelissa
Download Presentation

Understanding Java Programming Basics

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. Java some slides from Gaddis’ book (our textbook) supplemented/modified by Kaminski

  2. 2 types of Java programs Application Stand-alone program (no web browser) Relaxed security since user runs program locally Applet Small app embedded in a webpage - needs a Java enabled web browser to run app Enhanced security since user goes to a web page & applet runs itself

  3. Why Java (vs. other languages)? Java is “cross platform” So portable Program written for 1 type of device/HW/OS runs on ANY OTHER device/HW/OS without rewriting/recompiling program

  4. Normal Compiler Programmer writes program in high-level lang. (C, C#, COBOL,…) using text editor or IDE (Integrated Development Environment) saves it as a source code file = set of programming language statements Compiler translates source code into machine language = executable code (SomeProgram.exe) for a specific CPU / OS [simplistically]

  5. Compiler = a program IPO (Input / Processing / Output) translates: Input data: source code file Output data: machine language file also finds syntax errors spelling, grammar, structure errors that violate rules of that language .

  6. the Java “compiler” (& the JVM) Java compiler translates Java source file into a file containing byte code instructions Byte code instructions are the “machine language” of the Java Virtual Machine (JVM) & can NOT be executed directly by a CPU

  7. Java Virtual Machine (JVM) JVM = a program that emulates a HW CPU JVM executes each byte code instruction, as it’s read (unlike a compiler) an interpreter (vs. a true compiler) Java = an interpreted language

  8. Program Development Process Source code (.java) Saves Java statements Is read by Byte code(.class) Java compiler (javac) Produces Is interpreted by Program Execution Java Virtual Machine (java) Results in Text editor (or IDE)

  9. So Java programs are Portable Portable = program written for 1 type of computer runs on a wide variety of computers (with little/no modification) (e.g., applets) Java byte code runs on the JVM (on a computer), NOT on any particular CPU So “compiled” Java .class programs highly portable Specific JVM’s exist for many platforms: • Windows • Mac • Linux • Unix • etc.

  10. Portability Programs in other languages portable by: re-compiling program for each different platform / CPU so, many different .exe files required (what about applets for web?) Java provides a JVM for each platform so only 1 .class (byte code) file works everywhere Byte code program runs on ANY JVM

  11. You need JDK on your laptop JDK (Java Development Kit) software used to write Java programs different editions of JDK: Java SE - Standard Edition Java EE - Enterprise Edition Java ME - Micro Edition free download from Oracle

  12. 2 ways to compile Java program command-prompt (B&W) window javac is Java compiler (for specific JVM) to compile: javac SomeProgram.java IDE automates (& hides) this icon to build (instead of compile) automatic build when program is run

More Related