IT 114: Introduction to Java
Class 2
Topics
New Material
Homework
The first homework assignment is due this Sunday at 11:59 PM.
You will find the assignment here.
If you have a problem or a question, make a post on the Class Discussion Area.
Unix Lab Assistant
An IT student has been stationed in the Unix Lab to you with
your Unix questions.
They can also provide basic help with your assignments.
You can find details here.
This link also appears on the class web page.
New Material
We Will Be Using Unix in This Class
- All work in this course will be done on the Unix machine users3.cs.umb.edu
- You will need to connect to this machine from your computer
- This will mean that you will have to learn a few simple Unix commands to do your work
- But it will help you in your professional career
- A great deal of IT work can only be done at the command line
Working with Unix
- Working on the Unix command line takes some getting used to
- There are no menus on the command line
- You must type the name of the command and any arguments it needs
- Then hit Enter (PC) or Return (Mac)
- If you make a mistake you will get an error message which is usually not very helpful
- Fortunately, you only need to know a few Unix commands
- It will be frustrating at first
- But you will soon learn how to do what you need
- Be patient and ask for help in the class discussion area when you run into trouble
- You can also get help from other students
- And people in the Unix Lab on the 3rd floor of McCormack
Connecting to a Unix Machine
Your Home Directory
- When you first connect to the Unix machine you will be in your
home directory
- A directory
holds files and other directories
- It is called a folder on Windows and the Mac
- Every Unix account on our system has a home directory
- This directory belongs to you and you alone
- You have complete control over this directory
- If you enter the Unix command
ls
you will see what is inside this directory
ls
is short for "list"
- If you have completed the Apply process you should see an
it114 directory
The Hierarchical Filesystem
- Before we go any further, we needed to talk a little about the way Unix arranges files
- Unix uses a
hierarchical filesystem
- Which means that all files are kept in directories (folders)
- And directories live inside other directories
- With one special directory at the top called root
- Which is written as /
Moving To A Different Directory
- To move to a different directory you use the
cd
command
cd
stands for "change directory"
- The command has the following format
cd NAME_OF_DIRECTORY
- NAME_OF_DIRECTORY is a
placeholder
- When you use
cd
you replace NAME_OF_DIRECTORY
with the name of a directory
- To move to your it114 directory, type
cd it114
- The hierarchical filesystem can be a little confusing
- If you are ever confused by where you are when connected to Unix, there is a simple fix
- Use the
cd
command without an argument to go back to your home directory
Always Know Where You Are
- The hierarchical filesystem is like pyramid
- The root directory is at the top
- All other directories are inside this directory
- Or in sub-directories
- Or in sub-sub-Directories
- And so on
- The pyramid gets wider the deeper you go
- Many commands will not work properly if you are in the wrong directory
- Always know where you are in the hierarchical filesystem
- One way to learn your location is to use the
pwd
command
$ pwd
/home/olivia93
pwd stands for "print working directory"
Creating A New Directory
Looking at the Contents of a File
Compiled versus Interpreted Languages
- When you write a program in you create a text file
- This file consists of statements in the programming language
- This file is called the
source code
- But the computer does not understand the language of the source code
- It only understand programs in its own binary
machine language
- A program is needed to turn your source code into the binary code the machine understands
- There are two ways a program can do this
- It can create a new file, translating the source code into machine language
- It can run the program inside itself, translating the code line by line
- The programs that take the first approach are called
compilers
- Programs that take the second approach are called
interpreters
- The programming languages that take the first approach are compiled languages
- The programming languages that take the second approach are scripting languages
Compiled Languages
Scripting Languages
- Languages like Perl, Python and PHP are scripting languages
- In a scripting language the source code is not compiled
- So no executable file is created
- Instead the source code is run inside a program called an interpreter
- Interpreters are written in a compiled language like C
- But they must be compiled for specific machines
- Programs written in a scripting language run more slowly than than compile programs
Java Works Differently
- Java takes a middle course between compiled and interpreted languages
- You take a Java source file and run it through the Java compiler,
javac
- The source file must have the .java extension
- The compiler creates an
object file
with extension .class
- This object file does not contain machine language instructions
- Instead it contains what are called Java
bytecodes
- So you cannot run this .class file directly on the machine
- Instead you must run it inside the Java interpreter,
java
- The Java interpreter is also called the Java Runtime Environment (JRE)
- Or the Java Virtual Machine (JVM)
- Java interpreters have been written for all major platforms
- That means you can distribute a single set of .class files that will run on most machines
- Java gives developers most of the efficiency of a compiled language
- But the object files can be run almost anywhere
Today's Class Exercise
- In today's Class Exercise you will create directories for your homework assignments
- And your Class Exercises
- These directories must be named hw and ex
- And the must be inside your it114
- You will find the instructions here
Class Quiz
Attendance
Class Exercise