Presentation is loading. Please wait.

Presentation is loading. Please wait.

© copyright Janson Industries 2014

Similar presentations


Presentation on theme: "© copyright Janson Industries 2014"— Presentation transcript:

1 © copyright Janson Industries 2014
Java How the class works Java programming concepts Downloading the JDK Java coding and executing example Chapter 1 © copyright Janson Industries 2014

2 © copyright Janson Industries 2014
PP Presentations Can be viewed online or downloaded Go to: web.fscj.edu/Janson/COP2551 For all presentations and class files Chapter 1 © copyright Janson Industries 2014

3 © copyright Janson Industries 2014
Or you can go to my school website (web.fscj.edu/Janson) and click on this link Chapter 1 © copyright Janson Industries 2014

4 Click file name (link) to view online…
This presentation is 4thed.Ch01.ppt Click file name (link) to view online… Chapter 1 © copyright Janson Industries 2014

5 © copyright Janson Industries 2014
Or choose Save as Chapter 1 © copyright Janson Industries 2014

6 © copyright Janson Industries 2014
How Class Works Do the non-graded exercises first They will help you solve the graded assgs I can help you with these assgs/probs Keep track of the probs and solutions You will make the same mistakes many times Graded assgs (the Tutorials in the chapter and Challenge Exs) are for you (and you alone) to complete Chapter 1 © copyright Janson Industries 2014

7 © copyright Janson Industries 2014
How Class Works Tutorials (chapters 1-7) are 10% of your grade Challenge Exercises (Review Exercises at the end of chapters 1-7) are 20% Extra Credit (chapters 8-10 Tutorials) are extra 5% Must do non-graded assgs to get credit for graded assgs Chapter 1 © copyright Janson Industries 2014

8 © copyright Janson Industries 2014
How Class Works Tests are composed of 50 multiple choice questions To get an A you will have to do the Review Exercises Strongly advise you to do all of them You can also do the end of chapter challenge exercises If you can do all these you probably know the material Chapter 1 © copyright Janson Industries 2014

9 © copyright Janson Industries 2014
How Class Works If you come to a lecture, listen and take notes You will not learn the material by listening to the lecture and viewing the slides once You need to study/do the material covered in the lecture and examples And doing an exercise correctly once doesn’t necessarily mean you know it! This class assumes you all have WIN 7 Chapter 1 © copyright Janson Industries 2014

10 © copyright Janson Industries 2014
How Class Works You will need a thumb drive for the class to store all your assgs Suggestion: create a file named ICE or IFFOUND and put in some contact info for yourself This may mean you will get it back when you lose it ;-) Chapter 1 © copyright Janson Industries 2014

11 © copyright Janson Industries 2014
Classroom Computers The anti-virus s/w does not play nicely with RAD You need to sign on to the computers using the following: User id .\ibm PW cop2551 Chapter 1 © copyright Janson Industries 2014

12 How Class Works How long has it been since you took COP1000? Code.org
4/12/2018 How Class Works How long has it been since you took COP1000? Code.org Uses videos and games to get across the basic programming structures which you are already expected to understand

13 You can skip the video and go straight to the instructions
Once done with instruction, close window and try exercises

14 The first puzzle will start

15 There may be more instructions, click X's to close
When puzzle finished will allow you to continue to the next one or you can click to skip ahead There may be more instructions, click X's to close

16 Click Continue to go to next puzzle

17 Click Continue to go to next puzzle

18 If you can't figure it out, scroll down and click the help links

19 How Class Works There's an entire COP1000 set of lessons at
4/12/2018 How Class Works There's an entire COP1000 set of lessons at

20 Unplugged activites have the theory – good to read first
Then tackle the puzzles

21 © copyright Janson Industries 2014
Java Concepts Java source code stored in files with an extension of .java The source code is “compiled”, meaning: Translated into bytecode Bytecode stored in class files (files with an extension of .class) Bytecode is a “cross-platform program representation” that is non-executable Chapter 1 © copyright Janson Industries 2014

22 © copyright Janson Industries 2014
Java Concepts Cust.java (Java file) Cust.class (Class file) Java source code Java bytecode Editor Compiler Java source code javac Cust.java Programmer Programmer Chapter 1 © copyright Janson Industries 2014

23 © copyright Janson Industries 2014
Java Concepts Review: files with an extension of .java contain source code Review: files with an extension of .class contain “bytecode” .java files are “compiled” (javac) to create .class files Bytecode is a cross-platform program representation that is non-executable New: bytecode needs to be translated to machine language (java) Chapter 1 © copyright Janson Industries 2014

24 Java Virtual Machine (JVM)
JVM is “the place” (i.e. s/w) where the .class files (i.e. programs) are translated The JVM is invoked with the java command The JVM translates bytecode into machine language and sends to CPU for execution (i.e. program is run) Therefore, each "type" of computer needs a unique JVM Chapter 1 © copyright Janson Industries 2014

25 © copyright Janson Industries 2014
Java Concepts Cust.java (Java file) Cust.class (Class file) CPU Java source code Java bytecode main method in Machine Language Editor Compiler JVM Java source code javac Cust.java java Cust Programmer Programmer Programmer Chapter 1 © copyright Janson Industries 2014

26 Java Virtual Machine (JVM)
To run a java application on a computer you must download a JVM/JRE (java runtime environment) Oracle (and many other vendors) offer Oracle has a JDK (Java Development Kit) that includes a JRE (and compiler) Chapter 1 © copyright Janson Industries 2014

27 © copyright Janson Industries 2014
JDK (aka JSDK) Chapter 1 © copyright Janson Industries 2014

28 © copyright Janson Industries 2014
JDK on the PC Java JDK 8 is an example Use IE (not Chrome) to download the JDK: Select the latest version Click on the JDK download button for the latest update (i.e. JDK 8, or JDK8u60, etc.) Select the JDK for your computer (i.e. Windows) Download to thumb drive (G:) or your C drive (at home) Chapter 1 © copyright Janson Industries 2014

29 © copyright Janson Industries 2014
JDK on the PC To install the JDK: Run jdk-8(u#)-windows-i586-p.exe (where # is the latest version and update numbers) During the install, create folders to hold the JDK and JRE called jdk and jre Delete the original .exe file jdk-8(u#)-windows-i586-p.exe Chapter 1 © copyright Janson Industries 2014

30 Select the latest JDK version
Chapter 1 © copyright Janson Industries 2014

31 Scroll down and click the accept agreement radio button
Double click the operating system of the lab computers (Windows x86) Chapter 1 © copyright Janson Industries 2014

32 © copyright Janson Industries 2014
Specify to save the file by clicking the Save drop down button and then Save As Chapter 1 © copyright Janson Industries 2014

33 © copyright Janson Industries 2014
Create a folder called jdkzip on your thumb drive (or the C: if you will always being work on that same computer) and save the .exe file to jdkzip Chapter 1 © copyright Janson Industries 2014

34 Using My Computer open the jdkzip folder
Chapter 1 © copyright Janson Industries 2014

35 © copyright Janson Industries 2014
JDK on the PC Only takes up 165 meg Final install will take up ~180 meg Run the exe file by double clicking Click the Next button Chapter 1 © copyright Janson Industries 2014

36 If you get this, you downloaded the wrong JDK
Chapter 1 © copyright Janson Industries 2014

37 Or this (or any other msg), you downloaded the wrong JDK
Chapter 1 © copyright Janson Industries 2014

38 Accept the default components
(notice the JRE is just one part of the JDK) You can control where the JDK is installed by clicking the Change... button Chapter 1 © copyright Janson Industries 2014

39 © copyright Janson Industries 2014
To save on typing later, we’ll change directory to just JDK i.e. E:\JDK (or C:\JDK\) then click the OK button Chapter 1 © copyright Janson Industries 2014

40 JDK install window redisplayed with new location
Click Next Don't need to create the jdk folder first. Chapter 1 © copyright Janson Industries 2014

41 Shows where JRE will be installed. Change to…
Some students tell me this screen doesn’t appear, if it doesn’t – no problem, skip the next two slides. Chapter 1 © copyright Janson Industries 2014

42 Choose drive to save to, then click Make New Folder
Then specify jre, click OK Chapter 1 © copyright Janson Industries 2014

43 JRE install window redisplayed with new location, click Next
Chapter 1 © copyright Janson Industries 2014

44 You may have to shut down some running apps
Chapter 1 © copyright Janson Industries 2014

45 © copyright Janson Industries 2014
And again… Depending on where you installing, could take a while (a thumb drive will take longer than a hard drive) Chapter 1 © copyright Janson Industries 2014

46 Two folders called jdk and jre are created (verify with My Computer)
Delete jdkzip\jdk-8(u#)-windows-i586-p.exe and click the Close button Chapter 1 © copyright Janson Industries 2014

47 © copyright Janson Industries 2014
To verify that you installed correctly, display the contents of jdk/bin folder and make sure you have two executable files called javac and java Chapter 1 © copyright Janson Industries 2014

48 © copyright Janson Industries 2014
Running a pgm When you run a application in Windows, you are specifying an executable file name Executable files contain machine language On Windows machines these files have names that end in .exe Chapter 1 © copyright Janson Industries 2014

49 © copyright Janson Industries 2014
For instance, clicking the IE icon tells Windows to “run” iexplore.exe in C:\Program Files\Internet Explorer\ Chapter 1 © copyright Janson Industries 2014

50 © copyright Janson Industries 2014
C:\Program Files\Internet Explorer\iexplore.exe is a fully qualified file name Chapter 1 © copyright Janson Industries 2014

51 © copyright Janson Industries 2014
Running a pgm If a fully qualified file name is not specified, Windows searches 1. The default (aka current) directory 2. The locations stored in the the Environment Variable called PATH I.e. path holds all the locations Windows should search when an unqualified file name is specified You can control the value of the Path variable Let’s prove it!! Chapter 1 © copyright Janson Industries 2014

52 © copyright Janson Industries 2014
Running a pgm In command prompt we specify iexplore.exe You get the “Not recognized” message Now specify fully qualified file name (in quotes) Internet Explorer is started Start button, All Programs, Accessories, then Command Prompt or Start button, in search box type cmd, click on cmd.exe Chapter 1 © copyright Janson Industries 2014

53 © copyright Janson Industries 2014
Running a pgm Now we will set the path value path = "C:\Program Files\Internet Explorer\" In command prompt we specify iexplore.exe Internet Explorer started Chapter 1 © copyright Janson Industries 2014

54 © copyright Janson Industries 2014
Running a pgm JDK/bin must be in the PC’s path for Windows to access the compile (javac) and run (java) commands Path holds the locations to search for files Several ways to define path locations Each time you go to the command prompt (depending on where jdk installed) enter path=f:\jdk\bin or path=c:\jdk\bin Chapter 1 © copyright Janson Industries 2014

55 Running a pgm Start Notepad, enter source code, and save file with type of java F:\Customer.java (must specify type as All Files) Chapter 1 © copyright Janson Industries 2014

56 Running a pgm To run, bring up the Command Prompt by clicking:
Start, Accessories, Command Prompt Chapter 1 © copyright Janson Industries 2014

57 © copyright Janson Industries 2014
Running When javac and java commands are run, at first they do the same thing as Windows They check the default directory for the java and bytecode files If files not there, "file not found" msg displayed 2 solutions Change current directory to the location of the files with the CD (change directory) command CD F:\, hit Enter, then type F:, hit Enter again Include files location in classpath variable Chapter 1 © copyright Janson Industries 2014

58 © copyright Janson Industries 2014
Running 1. Issue the path command so that jdk/bin is in the path 2. If necessary, change the default path to the location of the java file (i.e. F:\ ) (type CD F:\, hit Enter, then type F:, hit Enter) 3. Convert to bytecode (javac Customer.java) 4. Convert bytecode to machine language and run the program (java Customer) Chapter 1 © copyright Janson Industries 2014

59 Running Prompt shows the default directory
Customer.java is on F:\ current directory is H:\ so “file not found” Must change current directory to location of Customer.java (i.e. F:\) Customer.java found cause default directory is F: Chapter 1 © copyright Janson Industries 2014

60 © copyright Janson Industries 2014
Running a pgm It’s that easy! But not very pretty both in terms of The application function and appearance The development environment So we’ll change how we do several things Chapter 1 © copyright Janson Industries 2014

61 Making Programming Easier
Easier ways to set up path and default dir Use an IDE (Integrated Development Environment) instead of notepad Eclipse Rational Application Developer (RAD) NetBeans Learn more java so that the application GUI is PURTY Chapter 1 © copyright Janson Industries 2014

62 © copyright Janson Industries 2014
JDK Install Problems? Error 1723 occurred in the installer package Lot’s of possible reasons Click here for some suggestions Chapter 1 © copyright Janson Industries 2014

63 © copyright Janson Industries 2014
Possible Problems? javac or java command is not recognized Why? Customer file not found: NoClassDefFoundError, ClassNotFoundException, could not find the main class Path not defined correctly. Common mistakes: wrong drive letter, incorrect directory name(s), extra spaces after bin, when installing you mixed up jdk and jre directories Path not defined correctly. Common mistakes: wrong drive letter, incorrect directory name(s), extra spaces after bin, when installing mixed up jdk and jre directories. Current directory not where Customer file is located (later Classpath not defined correctly) or file name not specified correctly (extra spaces, etc.) Current directory not where Customer file is located (or per book, Classpath not defined correctly) or file name not specified correctly (extra spaces, etc.) Chapter 1 © copyright Janson Industries 2014

64 © copyright Janson Industries 2014
Possible Problems? When there are Java syntax errors, JVM will show: A message with useful info File name: Customer.java Line number that has the error: 10 What the problem is: ‘;’ expected The source code statement(s) that have errors with ^ under where it thinks there are problems Chapter 1 © copyright Janson Industries 2014

65 © copyright Janson Industries 2014
Possible Problems? Common Java syntax errors Upper case/lower case letters are different If example shows upper case letter, you must use upper case letter Forward slash (/) back slash (\) are different println (means: print line) not printIn Chapter 1 © copyright Janson Industries 2014

66 © copyright Janson Industries 2014
Changes We’re going to use RAD instead of notepad Ch01a slides are next Chapter 1 © copyright Janson Industries 2014

67 © copyright Janson Industries 2014
But first…. Class exercise: Download the JDK to the F: or C: or... I suggest your thumb drive Install it Setup the path and default directory Enter the source code (exactly as shown on the slide) javac and java to run the program Chapter 1 © copyright Janson Industries 2014


Download ppt "© copyright Janson Industries 2014"

Similar presentations


Ads by Google