lab 1 preparation unix/linux background java language intro

15
Lab 1 Preparation UNIX/Linux background Java Language Intro

Upload: nathaniel-kennedy

Post on 30-Dec-2015

223 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Lab 1 Preparation UNIX/Linux background Java Language Intro

Lab 1 Preparation

UNIX/Linux background

Java Language Intro

Page 2: Lab 1 Preparation UNIX/Linux background Java Language Intro

UNIX/Linux Background

UNIX/Linux (*NIX) are operating systems– “Use small programs that are each good at one

thing”– Multiuser– Become a desktop OS

Why use it?– UNIX released in 1971

Legacy support for companies

– “Windows rot” and stability– Multiuser and security

Page 3: Lab 1 Preparation UNIX/Linux background Java Language Intro

Linux in the Lab

Page 4: Lab 1 Preparation UNIX/Linux background Java Language Intro

Navigating *NIX

Windows: Device based file system– C:\ hard drive, D:\ CD-ROM (for example)– You open the hardware you want, and then navigate

folders

*NIX: Mounting file system– / (root) and then directories. No direct notice of the

devices– Multi-users

Permissions Distinct file spaces

Page 5: Lab 1 Preparation UNIX/Linux background Java Language Intro

Navigating *NIX

/home/smiller

/home/smiller/stuff/more stuff/file.txt

/

Root Directory Sub-directory

HOME DIRECTORY

Sub-directory Sub-directory File

Root

Page 6: Lab 1 Preparation UNIX/Linux background Java Language Intro

Navigating *NIX

//

homehome

smillersmiller

otherother

binbin*NIX

C:\C:\

Documents & Settings

Documents & Settings

smillersmiller

otherother

Program Files

Program Files

WindowsMy

Documents

My Documents

Page 7: Lab 1 Preparation UNIX/Linux background Java Language Intro

Permissions

chmod <code> filename will change the permission of each entity to a file/directory– Owner, Group, Others (everyone else)– Read with ls -l as 3-value sets or read, write and

execute

Page 8: Lab 1 Preparation UNIX/Linux background Java Language Intro

Java Tutorial/Refresher

Java structure Static variables Calling other classes (Intro to OOP)

Page 9: Lab 1 Preparation UNIX/Linux background Java Language Intro

Java Language Structure

Packages - contain many related classes Classes – (generally) single .java files

containing variables and methods– Encapsulates and object– Classes encapsulate lots of similar “work” in many

methods

Method – function; unit of code that “does work” on data stored in an object

Page 10: Lab 1 Preparation UNIX/Linux background Java Language Intro

Static Variables

Static variables– Created at execution time for the program– Only available in scope where defined– Are never destroyed and therefore their values are

always available until program termination

Static methods can ONLY use static global variables

The main method is static for this reason Keep in mind for JSP

Page 11: Lab 1 Preparation UNIX/Linux background Java Language Intro

Calling Classes

A class has 4 main pieces– Class definition: name and type of class– Data: variables stored in class’ data structure– Methods: code that operates on the data in the

class– Constructor or main(): This is the entry point to the

class

Page 12: Lab 1 Preparation UNIX/Linux background Java Language Intro

Calling Classes

Think of how you create other variables: String, int, etc.– int myVariable = 100;– Creates an object of type integer and allocated the

memory (optionally initializes it) If you have a class to instantiate (create), you

call it the same way– MyClass myVariable;– To initialize it: MyClass myVariable = new

MyClass(arguments);

Page 13: Lab 1 Preparation UNIX/Linux background Java Language Intro

Calling Classes

Much like classes you have used in CSC110, you call a method in a class with a ‘.’

MyClass myVariable;

myVariable.doSomething();

System.out.print(“We did something”);

Page 14: Lab 1 Preparation UNIX/Linux background Java Language Intro

Classes and Java

Java provides nearly any function you’d need to do common tasks (including networking) in provided classes. You need to create objects containing the functionality you need.

Page 15: Lab 1 Preparation UNIX/Linux background Java Language Intro

NEXT CLASS

Object-Oriented Programming and finishing Networking slides

Finish Lab 1 and be ready to submit it