Installing Java on a Home machine l For

  • Slides: 19
Download presentation
Installing Java on a Home machine l For Windows Users: Download/Install: Go to l

Installing Java on a Home machine l For Windows Users: Download/Install: Go to l http: //www. oracle. com/technetwork/javase/downloads/jdk 8 downloads-2133151. html Accept License Agreement and then download the file named “jdk-8 u 171 -windows-i 586. exe”. Save the file to the desktop and run it. The installer will install Java to: C: Program FilesJavajdk 1. 8. 0_171 Once the installer is finished, you must set your computer's path before Java will work correctly.

Installing Java on a Home machine (cont’d) l Setting the Path: Go to the

Installing Java on a Home machine (cont’d) l Setting the Path: Go to the Control Panel and double-click System Select the Advanced tab Click on the Environment Variables button Look under System Variables for "Path" Click on "Path" and then click edit Add the following to the end of the Path ; C: Program FilesJavajdk 1. 8. 0_171bin Click OK. Click the "New" button. For the variable name, type: CLASSPATH For the value, type: . ; NOTE: The above value in words is period semicolon; it is not a misprint. Click OK. Exit out of all the open windows

Installing Java on a Home machine (cont’d) l To test if java is installed

Installing Java on a Home machine (cont’d) l To test if java is installed correctly: Open up a command prompt To do this click on Start and then Run Type in cmd. exe and click Ok Type java and hit enter If you see something like "command not found", then java is not installed correctly Otherwise you should see a list of options for running java

Developing a programming skill Learning to program a computer l l Training yourself to

Developing a programming skill Learning to program a computer l l Training yourself to solve problems l in a very detailed and organized manner You are already experienced in l l Intuitive problem solving Need to develop programming skill l l Write a problem solution l IN terms of actions appropriate for a computer

Computer organization Computer system l l l Hardware l physical, tangible pieces such as

Computer organization Computer system l l l Hardware l physical, tangible pieces such as chips, wires, and so on l Useless without instructions to tell them what to do l Driven by a series of instructions, in other words programs Software l Programs and the data those programs use l Intangible counterpart to the physical hardware components

Computer hardware Most computer have four major hardware parts l l l Central Processing

Computer hardware Most computer have four major hardware parts l l l Central Processing Unit (CPU): l brain of the computer l executes individual commands of a program Input/output devices l l allow human beings to interact with a computer Memory l stores programs and data while being processed by CPU

Computer hardware (cont’d) Memory Input devices Output devices CPU

Computer hardware (cont’d) Memory Input devices Output devices CPU

What is programming l Computers performs tasks l more efficiently, quickly, and accurately than

What is programming l Computers performs tasks l more efficiently, quickly, and accurately than we could by hand l However, to be useful it must be programmed l l Computer programming: l Devise a set of instructions l l to be executed by a computer In order to solve a given real world problem

How do we write a program? l It is a two phase process Problem-Solving

How do we write a program? l It is a two phase process Problem-Solving Phase Analysis and specification General solution (Algorithm) Implementation Phase Concrete solution (Program) Test Verify Maintenance Phase

Algorithm implementation JAVA code Algorithm C++ code Ada code Algorithm translated into different languages

Algorithm implementation JAVA code Algorithm C++ code Ada code Algorithm translated into different languages Peter’s JAVA code Algorithm Nell’s JAVA code John’s JAVA code Algorithm translated by different people

Programming shortcut Problem Solving Phase (Algorithm) Shortcut? Implementation Phase (code) Think first and code

Programming shortcut Problem Solving Phase (Algorithm) Shortcut? Implementation Phase (code) Think first and code later

JAVA program execution l convert Java code to a form usable by computers l

JAVA program execution l convert Java code to a form usable by computers l provided that in a computer instructions and data l l In a computer, l l are stored in the computer memories using binary codes data represented by pulses of electricity l On circuit => ‘ 1’; Off circuit => ‘ 0’ l Data in binary form => combination of enough 1 s and 0 s Program execution means l translating data and instructions to patterns of 1 s and 0 s.

Programming language levels l Machine language l Primitive instruction built into each machine l

Programming language levels l Machine language l Primitive instruction built into each machine l Each type of CPU has its own language l Binary based instructions l l => tedious process and prone to error Assembly language l Short English like words for commands and data l Tedious to use Both are considered to be low level languages

Programming language levels (cont’d) l High level language l Expressed in English like phrases

Programming language levels (cont’d) l High level language l Expressed in English like phrases l Easier to read and write High level Language Assembly Language Machine Language a+b ld [%fp-20] %o 0 1101 0000 0111 ld [%fp-20] %o 1 1101 0010 0000 0111 add %o 0, %o 1 1011 1110 1000

Program development l Software tools involved l Editor: type a program and store in

Program development l Software tools involved l Editor: type a program and store in a file l Translation from high level into executable form l l That translation may result in errors l You change the code to fix the problem Execute the program and evaluate results errors Edit and save program Translate program errors Execute program

Compilers l Translation into machine language l Compiler: l Translates code in one language

Compilers l Translation into machine language l Compiler: l Translates code in one language § to equivalent code in another one l Original code => source code, l Target language => particular machine language l Translate once and run whenever needed

Interpreters l Translation into machine language l Interpreter l similar to compiler with some

Interpreters l Translation into machine language l Interpreter l similar to compiler with some differences l Interweaves the translation and execution l Parts of the source code § are translated and executed one at a time l Drawback: § Programs run more slowly, § as translation occurs during execution

JAVA translation and execution l The process l l combines the use of a

JAVA translation and execution l The process l l combines the use of a compiler and interpreter l Java source code -> Bytecode (Java compiler) l JAVA virtual machine reads bytecode and executes it Difference between Bytecode and machine language l Bytecode is not tied to any particular processor type l It makes JAVA architecture neutral => portable

JAVA translation and execution (cont’d) JAVA Source code JAVA compiler JAVA bytecode JAVA interpreter

JAVA translation and execution (cont’d) JAVA Source code JAVA compiler JAVA bytecode JAVA interpreter Bytecode compiler Machine code