lab 1 preparation unix/linux background java language intro
TRANSCRIPT
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
Linux in the Lab
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
Navigating *NIX
/home/smiller
/home/smiller/stuff/more stuff/file.txt
/
Root Directory Sub-directory
HOME DIRECTORY
Sub-directory Sub-directory File
Root
Navigating *NIX
//
homehome
smillersmiller
otherother
binbin*NIX
C:\C:\
Documents & Settings
Documents & Settings
smillersmiller
otherother
Program Files
Program Files
WindowsMy
Documents
My Documents
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
Java Tutorial/Refresher
Java structure Static variables Calling other classes (Intro to OOP)
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
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
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
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);
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”);
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.
NEXT CLASS
Object-Oriented Programming and finishing Networking slides
Finish Lab 1 and be ready to submit it