Courses‎ > ‎AP Computer Science‎ > ‎Konstantinovich‎ > ‎notes‎ > ‎

2017-09-11 HW

posted Sep 11, 2017, 6:23 AM by Samuel Konstantinovich   [ updated Sep 11, 2017, 9:38 AM ]
Goal: Course overview + Your terminal fu is no good here...

Homework: Test your ability to compile and run (see end of lecture)

School network:

lisa.stuy.edu  149.89.160.100
homer.stuy.edu 149.89.150.100
bart.stuy.edu  149.89.151.100
marge.stuy.edu 149.89.161.100

307:   149.89.150.xxx  
cslab1-1 ... cslab1-30  where xxx is 101-130

325:   149.89.151.xxx  
cslab2-1 ... cslab2-30  where xxx is 101-130

251:   149.89.160.xxx  
cslab3-1 ... cslab3-31  where xxx is 101-131

451:   149.89.161.xxx  
cslab4-1 ... cslab4-32  where xxx is 101-132

Inside the building you can SSH to any host using its ip address.

The *nix command is: 
ssh user@host

Win: you have to use puTTY or another ssh program.



Resources:
Very Basic Linux Tutorial for n00bs and forgetful people:  https://www.digitalocean.com/community/articles/an-introduction-to-linux-basics

More detailed Linux/Unix tutorial:







Java code for reference:

EXAMPLE 1:

file: helloworld.java

public class helloworld{
    public static void main(String[]args){
        System.out.println("Hello world");
    }
}

EXAMPLE 2
file: Demo.java

public class Demo{

    public static void print( int x){
        System.out.println("This was a function!");
        System.out.println("The parameter is "+ x);        
    }

    public static void main(String[]args){    
        print(5);
        print(-2);

    }
}



HW Test the JDK by running this on a terminal:  
javac -version
1. Paste the following into HelloWorld.java :
public class HelloWorld{
    public static void main(String[]args){
        System.out.println("Hello, my name is Inigo Montoya, You killed my");
        System.out.println("father, prepare to die!");
    }
}

2. Open a terminal and cd into the same directory as your file, then run the commands:
javac HelloWorld.java
java HelloWorld



If in a terminal you cannot just type 
java
javac

Then you need to set your environment variables. Google the following:

javac environment variables <OS>           

*Replace <OS> with your operating system.

e.g.
javac environment variables windows 10
javac environment variables windows 7

Comments