Command Line Interface for Java

Command Line Interface for Java 1 / 13 Command Line Interface for Java Mikhail Andrenkov Department of Computing and Software McMaster University W...
Author: Everett Lawson
4 downloads 0 Views 243KB Size
Command Line Interface for Java

1 / 13

Command Line Interface for Java Mikhail Andrenkov

Department of Computing and Software McMaster University Week 2: Sept 19 - 23

Mikhail Andrenkov

Command Line Interface for Java

1 / 13

Command Line Interface for Java

2 / 13

Outline

Outline 1

Method 1: Local Verify Java Installation Compile and Run Packages

2

Method 2: Remote Windows Upload HelloWorld Log in to Server Compile and Run

OS X/Linux Upload HelloWorld Log in to Server Compile and Run

Mikhail Andrenkov

Command Line Interface for Java

2 / 13

Command Line Interface for Java

3 / 13

Method 1: Local

Download HelloWorld

HelloWorld.java from: http://www.cas. mcmaster.ca/~cs2s03/tutorials/HelloWorld.java

1 Download

Mikhail Andrenkov

Command Line Interface for Java

3 / 13

Command Line Interface for Java

4 / 13

Method 1: Local Verify Java Installation

Verify Java Installation: Windows Windows

1 Open Command Prompt 2 Execute

javac -version javac 1.8.0_102 'javac' is not a recognized command:

The output should be: If the output is:

1

be

2 3

javac installation. By default, C:\Program Files\Java\jdk1.8.0_102\bin.

Find the path to your

it should

Open Control Panel Navigate to: System



Advanced system settings



Environment Variables...

4 5 6

Under 'System variables', select 'Path' and click 'Edit...' Click 'New' and enter the path to your

javac

directory

Restart Command Prompt

Ask a TA if you need help nding the path

Mikhail Andrenkov

Command Line Interface for Java

4 / 13

Command Line Interface for Java

5 / 13

Method 1: Local Verify Java Installation

Verify Installation: OS X/Linux

OS X/Linux

1 Open Terminal 2 Execute

javac -version javac 1.8.0_102 -bash: javac: command not found, then modify ~/.bash_profile to include the line:

The output should be: If instead you get you may need to

export PATH=/path/to/java/bin:$PATH Ask a TA if you need help nding the path

Mikhail Andrenkov

Command Line Interface for Java

5 / 13

Command Line Interface for Java

6 / 13

Method 1: Local Compile and Run

Compile and Run Locally Windows/OS X/Linux

1 2 3 4

cd /path/to/Downloads/ ls (dir in Command Prompt) and conrm that you are the directory containing HelloWorld.java Compile the Java source le: javac HelloWorld.java Execute the compiled Java le: java HelloWorld

in

Hello, and welcome to CS2S03!

Mikhail Andrenkov

Command Line Interface for Java

6 / 13

Command Line Interface for Java

7 / 13

Method 1: Local Compile and Run

Compile and Run Packages Windows/OS X/Linux

1 Ensure you are in the directory with 2 3

HelloWorld.java

mkdir pkg mv HelloWorld.java /pkg/HelloWorld.java (move

in

Command Prompt)

4

cd pkg

5 Add  package 6 Compile and

pkg; to the top of HelloWorld.java execute HelloWorld.java

7 Did this work? Try the following: 1 cd .. 2 java pkg/HelloWorld

Hello, and welcome to CS2S03! Mikhail Andrenkov

Command Line Interface for Java

7 / 13

Command Line Interface for Java

8 / 13

Method 2: Remote Windows

Upload HelloWorld: Windows FileZilla from https: //filezilla-project.org/download.php?type=client

1 Download and install

2 Careful! Be sure to select Advanced installation and uncheck all the bloatware.

3 Enter the following details in the connection bar: 1 2 3

Host:

sftp://mills.mcmaster.ca

Username and Password: Use Mosaic credentials Port: 22

4 Find your downloaded

HelloWorld.java

in the left (local)

pane and drag it over to the right (remote) pane to upload it to the server

Mikhail Andrenkov

Command Line Interface for Java

8 / 13

Command Line Interface for Java

9 / 13

Method 2: Remote Windows

Log in to Server: Windows

putty.exe from http://www.chiark. greenend.org.uk/~sgtatham/putty/download.html

1 Download and install

Note: You don't need to install PuTTY. Just double-click putty.exe to run it

2 Enter the following details in the conguration window: Host:

mills.mcmaster.ca

Port: 22

3 Click `Open'

Mikhail Andrenkov

Command Line Interface for Java

9 / 13

Command Line Interface for Java

10 / 13

Method 2: Remote Windows

Compile and Run Remotely: Windows

1 Enter your MacID and password when requested.

Note: 2

No characters will appear when you type your password

ls and conrm

that your

HelloWorld.java le

was uploaded

successfully

javac HelloWorld.java le: java HelloWorld

3 Compile the Java source le: 4 Execute the compiled Java

Hello, and welcome to CS2S03!

Mikhail Andrenkov

Command Line Interface for Java

10 / 13

Command Line Interface for Java

11 / 13

Method 2: Remote OS X/Linux

Upload HelloWorld: OS X/Linux

1 Open Terminal 2 3 4

cd /path/to/Downloads/ ls and conrm that you are in the directory containing HelloWorld.java scp HelloWorld.java [email protected]:~

to

upload the le to your home directory on the Mills server

Mikhail Andrenkov

Command Line Interface for Java

11 / 13

Command Line Interface for Java

12 / 13

Method 2: Remote OS X/Linux

Log in to Server: OS X/Linux

1

ssh [email protected]

to log in to the server.

2 Enter your MacID and password when requested.

Note:

No characters will appear when you type your password

Mikhail Andrenkov

Command Line Interface for Java

12 / 13

Command Line Interface for Java

13 / 13

Method 2: Remote OS X/Linux

Compile and Run: OS X/Linux

1

ls and conrm

that your

HelloWorld.java le

was uploaded

successfully

javac HelloWorld.java le: java HelloWorld

2 Compile the Java source le: 3 Execute the compiled Java

Hello, and welcome to CS2S03!

Mikhail Andrenkov

Command Line Interface for Java

13 / 13

Suggest Documents