Download Java Environment

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Java Environment
CSCI 201
Principles of Software Development
Jeffrey Miller, Ph.D.
[email protected]
Outline
• Java Environment
• Eclipse Tutorial
USC CSCI 201L
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 8, released in 2013 with few updates
since
▪ Java is open source
▪ http://java.sun.com
• Java Environment
USC CSCI 201L
3/23
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
• Java Environment
USC CSCI 201L
4/23
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
• Java Environment
USC CSCI 201L
5/23
IDE
▪ There are many Integrated Development Environments to
use
›
›
›
›
›
Eclipse
NetBeans
IntelliJ
Visual J++
Others?
• Java Environment
USC CSCI 201L
6/23
Outline
• Java Environment
• Eclipse Tutorial
USC CSCI 201L
Downloading Eclipse
▪ Go to http://www.eclipse.org
• Eclipse Tutorial
USC CSCI 201L
8/23
Downloading Eclipse
▪ Click Downloads
• Eclipse Tutorial
USC CSCI 201L
9/23
Downloading Eclipse
▪ Select your OS (if not already selected) then click the
version for the Eclipse IDE for Java Developers
• Eclipse Tutorial
USC CSCI 201L
10/23
Downloading Eclipse
▪ Click the green arrow next to the selected mirror
• Eclipse Tutorial
USC CSCI 201L
11/23
Downloading Eclipse
▪ Save the zip file
• Eclipse Tutorial
USC CSCI 201L
12/23
Downloading Eclipse
▪ Open the zip file and drag the “eclipse” directory to your
Desktop (or another directory of your choosing)
• Eclipse Tutorial
USC CSCI 201L
13/23
Running Eclipse
▪ After the zip file finishes extracting, open the “eclipse”
directory and run the eclipse executable
• Eclipse Tutorial
USC CSCI 201L
14/23
Running Eclipse
▪ Select a workspace directory
› The workspace directory will be the one that contains all of
your projects, code, and compiled files
• Eclipse Tutorial
USC CSCI 201L
15/23
Creating a Project
▪ Go to File->New->Java Project
• Eclipse Tutorial
USC CSCI 201L
16/23
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
• Eclipse Tutorial
USC CSCI 201L
17/23
Create a Class
▪ Expand the Project by clicking the arrow next to the
name of the project you just created
• Eclipse Tutorial
USC CSCI 201L
18/23
Create a Class
▪ Right-click on “src” and go to New->Class
• Eclipse Tutorial
USC CSCI 201L
19/23
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
• Eclipse Tutorial
USC CSCI 201L
20/23
Write Some Code
▪ You should now have a nearly-blank file and can begin
writing code
• Eclipse Tutorial
USC CSCI 201L
21/23
Write Some Code
▪ Type the following code into the HelloCSCI201.java file
• Eclipse Tutorial
USC CSCI 201L
22/23
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
• Eclipse Tutorial
USC CSCI 201L
23/23