java environment - university of southern californiacsci201/lectures/lecture1/environment.pdf ·...
TRANSCRIPT
![Page 2: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/2.jpg)
Outline
• Java Environment• Eclipse Tutorial
USC CSCI 201L
![Page 3: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/3.jpg)
History of Java
▪ Java was created by Sun Microsystems› First version 1.0 was released in 1996
▪ Sun Microsystems was bought by Oracle in 2010▪ Java has gone through numerous major and minor releases
› Current major version is Java 10, released in 2018 with few updates since
▪ Java is open source▪ http://java.sun.com
USC CSCI 201L 3/23• Java Environment
![Page 4: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/4.jpg)
Compiling▪ Java has a motto of “write once, run anywhere”
› When code is compiled, it produces byte code instead of a binary executable
› The Java Virtual Machine (JVM) is compiled for a specific operating system, then allowing for the byte code to run on any operating system (for which there is a JVM)
› Since the JVM is written in a native language, there may be subtle, or not-so-subtle, differences when run on different JVMs
▪ Java may run slightly slower than compiled native languages
USC CSCI 201L 4/23• Java Environment
![Page 5: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/5.jpg)
Command Line▪ You can write with any text editor you want and compile
it from a command line that has the Java Development Kit (JDK) installed
USC CSCI 201L 5/23• Java Environment
![Page 6: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/6.jpg)
IDE▪ There are many Integrated Development Environments to
use› Eclipse› NetBeans› IntelliJ› Visual J++› Others?
USC CSCI 201L 6/23• Java Environment
![Page 7: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/7.jpg)
Outline
• Java Environment• Eclipse Tutorial
USC CSCI 201L
![Page 8: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/8.jpg)
Downloading Eclipse▪ Go to http://www.eclipse.org
USC CSCI 201L 8/23• Eclipse Tutorial
![Page 9: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/9.jpg)
Downloading Eclipse▪ Click Downloads
USC CSCI 201L 9/23• Eclipse Tutorial
![Page 10: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/10.jpg)
Downloading Eclipse▪ Select your OS (if not already selected) then click the
version for the Eclipse IDE for Java Developers
USC CSCI 201L 10/23• Eclipse Tutorial
![Page 11: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/11.jpg)
Downloading Eclipse▪ Click the green arrow next to the selected mirror
USC CSCI 201L 11/23• Eclipse Tutorial
![Page 12: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/12.jpg)
Downloading Eclipse▪ Save the zip file
USC CSCI 201L 12/23• Eclipse Tutorial
![Page 13: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/13.jpg)
Downloading Eclipse▪ Open the zip file and drag the “eclipse” directory to your
Desktop (or another directory of your choosing)
USC CSCI 201L 13/23• Eclipse Tutorial
![Page 14: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/14.jpg)
Running Eclipse▪ After the zip file finishes extracting, open the “eclipse”
directory and run the eclipse executable
USC CSCI 201L 14/23• Eclipse Tutorial
![Page 15: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/15.jpg)
Running Eclipse▪ Select a workspace directory
› The workspace directory will be the one that contains all of your projects, code, and compiled files
USC CSCI 201L 15/23• Eclipse Tutorial
![Page 16: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/16.jpg)
Creating a Project▪ Go to File->New->Java Project
USC CSCI 201L 16/23• Eclipse Tutorial
![Page 17: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/17.jpg)
Create a Project ▪ Type a name for the Project and click Finish
› This has nothing to do with the code, but it should be descriptive enough for you to know what code is in the project
USC CSCI 201L 17/23• Eclipse Tutorial
![Page 18: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/18.jpg)
Create a Class▪ Expand the Project by clicking the arrow next to the
name of the project you just created
USC CSCI 201L 18/23• Eclipse Tutorial
![Page 19: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/19.jpg)
Create a Class▪ Right-click on “src” and go to New->Class
USC CSCI 201L 19/23• Eclipse Tutorial
![Page 20: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/20.jpg)
Create a Class▪ Type a name for the class and uncheck all other boxes
(unless you want Eclipse to generate code for you), then click Finish
USC CSCI 201L 20/23• Eclipse Tutorial
![Page 21: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/21.jpg)
Write Some Code▪ You should now have a nearly-blank file and can begin
writing code
USC CSCI 201L 21/23• Eclipse Tutorial
![Page 22: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/22.jpg)
Write Some Code▪ Type the following code into the HelloCSCI201.java file
USC CSCI 201L 22/23• Eclipse Tutorial
![Page 23: Java Environment - University of Southern Californiacsci201/lectures/Lecture1/Environment.pdf · Java Environment CSCI 201. Principles of Software Development. Jeffrey Miller, Ph.D](https://reader034.vdocuments.site/reader034/viewer/2022042208/5eabd8ab349a6222103701dd/html5/thumbnails/23.jpg)
Running the Code▪ Click the green play button at the top to run your code
› If your code doesn’t compile, you will have error messages at the bottom of the screen
› If your code compiles, your output will be at the bottom of the screen
USC CSCI 201L 23/23• Eclipse Tutorial