Download presentation
Presentation is loading. Please wait.
Published byLindsay Oliver Modified over 9 years ago
1
CS413: Java Programming language Applications Applets
Conceived by Sun Microsystems Benefits Runs on any Java enabled Web Browser No installation or setup adjustments No need to scan for viruses Can create large graphics (charts, tables) on the fly No need to download large graphics Increase download speed Security Features Runtime examination: program is examined line-by-line for valid Java only code Restricted Interactivity: Built-in restrictions on establishing connections to other computers The Java applet can only connect to the Internet location it came from Restricted Access Rights: Built in restrictions on a program being able to read and write data A program can only access the parts of a computer where it has received advance permission to access
2
CS413: Java Usage samples Interaction with a user Calculate information of a web page Administer a quiz ‘Dress’ a web page Control animation on a web page Control GUI interfaces Open System Any hardware or software product that matches the published specifications Published specifications establish a shared definition of how components must work together Sun Microsystems has published detailed specifications for Java A program written in Java can run on any Java-enabled system with no adaptation required Permits programs to be: More widely distributed More easily easily used
3
CS413: Java Java Applet (Internet Web Page)
Manipulate words, numbers, and pictures Create and control GUI interface Display windows, buttons, and menus User to point and click with a mouse to control actions Information displayed in a variety of colours, styles, and sizes Graphical User Interface (GUI) Enables the user to do all of the above to make the web page/site easier and more interesting to use
4
CS413: Java Java Applet A mini program written Java and attached to a web page Fast to download Enhance the web page display Enable the user to interact with the web page Enable the user to complete specific tasks Manipulates data Creates graphics
5
CS413: Java Programmer User Text file Extension of .java
Source Code anyname.java Java compiler Java compiler javac Applet file ‘Bytecode’ anyname.class Executable Java applet .class HTML page HTML page anyname.html Java enabled browser anyname.html HTML page Java translator anyname.html User
6
CS413: Java Assembler Compiler
Creates a machine language executable file (program) Programs written in Assembler language Each Assembler language instruction generates one machine language instruction Fast execution Compiler Programs written in higher level languages COBOL, PL1, RPG, FORTRAN Each programming language instruction generates one or more machine language instructions
7
CS413: Java Translator DOES NOT create machine language executable file (program) Limited instruction set (compared to Assembly and Compiler languages) Slow processing Every instruction is read from the input file and processed individually 1. Instruction is read into the translator 2. Converted by the ‘Translator’ to 1 or more machine language instructions 3. Instruction is executed 4. Cycle starts again with next instruction Slow processing due to Loops Decision blocks
8
Java creation/compile/execution (translation) Using DOS
CS413: Java Java creation/compile/execution (translation) Using DOS Create the Java code in a text editor Save the file somename.java extension Open a DOS window Enter path command at the c:\windows> prompt path=c:\jdk1.2.2\bin Change DOS directory to where the .java file is located Enter javac somename.java To compile the Java code to a .class file Fix any errors and re-compile (Step 6) When no more errors - continue Enter java somename To execute the compiled version
9
CS413: Java Java creation/compile/execution (translation) Using Java Development Kit (JDK)
10
LAB I: Java program CS413: Java import java.applet.*;
import java.awt.*; /** This is a comment block */ public class HelloWorld extends Applet { Label helloLabel = new Label(“Yo, you lookin’ at me?”); public void init() { setBackground(Color.yellow); add(helloLabel); }
11
CS413: Java Java code in a Web page Basic HTML Document
Create an HTML document in a text editor Save as .htm or .html file Insert the following Java code in the <body> area of the HTML file <APPLET CODE= “somename.class” width=300 height = 50></APPLET> Open the .htm/.html file in a browser Basic HTML Document <HTML> <HEAD> <TITLE></TITLE> </HEAD> <BODY> </BODY> </HTML>
12
Java Program Description
CS413: Java Java Program Description import java.applet.*; Reference a Java library of pre-written code * = make all library code members accessible import java.awt.*; Reference a Java library of pre-written code * = make all library code members accessible /** begin comment area This is a comment block */ end comment area public class HelloWorld extends Applet { public = the applet is accessible by outside programs class = defines this applet as a Java class HelloWorld = name of the Java class extends Applet = required for a Java class declaration Label helloLabel = new Label(“Yo, you lookin’ at me?”); Label = Java code from the Java.awt library Display something on the screen helloLabel = programmer name of the Label new Label = Java definition creating the Label ( ….) = Text to be displayed on the screen
13
Java Program Description
CS413: Java Java Program Description public void init() { Define what is to happen at applet initalization setBackground(Color.yellow); Set the background color to yellow add(helloLabel); Add the data from helloLabel to the graphic } end of ‘public void’ method } end of entire applet
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.