Lecture 4: Introduction to Java and your Development Environment

Similar documents
COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

Getting Started with Java. Atul Prakash

II. Compiling and launching from Command-Line, IDE A simple JAVA program

Computational Applications in Nuclear Astrophysics using Java Java course Lecture 1

C02: Overview of Software Development and Java

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017

Kickstart Intro to Java Part I

IT151: Introduction to Programming (java)

Fundamentals of Programming. By Budditha Hettige

CS110/CS119 Introduction to Computing (Java) Bob Wilson S-3-176

CHAPTER 1 Introduction to Computers and Java

Index. Course Outline. Grading Policy. Lab Time Distribution. Important Instructions

Getting Started with Eclipse/Java

CompSci 125 Lecture 02

Lecture 1 - Introduction (Class Notes)

CS 11 java track: lecture 1

CHAPTER 1. Introduction to JAVA Programming

Class 1: Homework. Intro to Computer Science CSCI-UA.0101 New York University Courant Institute of Mathematical Sciences Fall 2017

Introduction to Java Programming

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

How to Install (then Test) the NetBeans Bundle

AP Computer Science A: Java Programming

Java Programming. Zheng-Liang Lu. Java 308 Spring Department of Computer Science & Information Engineering National Taiwan University

Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer? A Bit of History

An Introduction to Software Engineering. David Greenstein Monta Vista High School

Lecture 1: Overview of Java

Section 2.2 Your First Program in Java: Printing a Line of Text

Certified Core Java Developer VS-1036

CSC116: Introduction to Computing - Java

Programming with Java

CSE 421 Course Overview and Introduction to Java

Introduction to Java

COMP-202 Unit 0: Course Details

CSC116: Introduction to Computing - Java

Exercise 1: Intro to Java & Eclipse

Lesson 04: Our First Java Program (W01D4

Java Puzzle Ball Nick Ristuccia

Introduction. Introduction to OOP with Java. Lecture 01: Introduction to OOP with Java - AKF Sep AbuKhleiF -

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

JAVA Programming Practice Course Overview Lecture Schedule Today s Task Contact

Java Programming. Zheng-Liang Lu. Java 301 Summer Department of Computer Science & Information Engineering National Taiwan University

Lecture 02, Fall 2018 Friday September 7

CSC116: Introduction to Computing - Java

Introduction Basic elements of Java

COMP250: Introduction to Computer Science. Jérôme Waldispühl & Carlos Oliver Gonzalez School of Computer Science McGill University

Software Practice 1. Course Overview Lecture Schedule Today s Task Contact

Lesson 01 Introduction

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

Full file at

Lecture 1: Introduction to Java

The Command Shell. Fundamentals of Computer Science

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Tutorial 1 CSC 201. Java Programming Concepts عؾادئماظربجمةمبادؿكدامماجلاصا

CMSC 150 LECTURE 1 INTRODUCTION TO COURSE COMPUTER SCIENCE HELLO WORLD

G52PGP. Lecture oo3 Java (A real object oriented language)

3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

Chapter 1 Introduction to Computers, Programs, and Java

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015

MEAP Edition Manning Early Access Program Get Programming with Java Version 1

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016

For live Java EE training, please see training courses at

Eclipse Environment Setup

Chapter 1 Introduction to Java

Java Language. Programs. Computer programs, known as software, are instructions to the computer. You tell a computer what to do through programs.

Project 1. Java Control Structures 1/17/2014. Project 1 and Java Intro. Project 1 (2) To familiarize with

Programming 1 - Honors

Introduction to Data Structures

Introduction to Java

COMP-202A: Introduction to Computing 1

COMP Foundations of Programming

COMP 215: INTRO TO PROGRAM DESIGN. Prof. Chris Jermaine Chris Prof. Chris Dr. Chris

CS 241 Data Organization. August 21, 2018

Crash Course Review Only. Please use online Jasmit Singh 2

Java with Eclipse: Setup & Getting Started

COMP6700/2140 JDK Tools

CT 229. CT229 Lecture Notes. Labs. Tutorials. Lecture Notes. Programming II CT229. Objectives for CT229. IT Department NUI Galway

CS 231 Data Structures and Algorithms, Fall 2016

Get JAVA. I will just tell you what I did (on January 10, 2017). I went to:

Code Ninjas: Introduction to Computer Science. Macomb Science Olympiad Presented by Swati Dharia

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

CS 101 : Introduction to Programming. Lecture 1 22/January/2018 Ashish Sureka

CPSC 150 Laboratory Manual. Lab 1 Introduction to Program Creation

CS520 Setting Up the Programming Environment for Windows Suresh Kalathur. For Windows users, download the Java8 SDK as shown below.

AP Computer Science Summer Assignment (updated 5/29/2018) DUE : Sept. 4, 2018

COMP-202B: Foundations of Programming

COMP-202C: Foundations of Programming

13 th Windsor Regional Secondary School Computer Programming Competition

CS 152: Data Structures with Java Hello World with the IntelliJ IDE

Summer Assignment for AP Computer Science. Room 302

Inf1-OP. Course Overview. Volker Seeker, adapting earlier version by Perdita Stevens and Ewan Klein. February 26, School of Informatics

AP Computer Science A

Chapter 3 Intro to Java

Setup and Getting Startedt Customized Java EE Training:

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

CS Week 2. Jim Williams, PhD

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

Java Bytecode (binary file)

Transcription:

Lecture 4: Introduction to Java and your Development Environment COMP 250 Winter 2018 Carlos G. Oliver, Jérôme Waldispühl Slides adapted from Mathieu Blanchette 1

2

About me» 2nd Year PhD Student in Computer Science» B.Sc. CS & Bio, MSc Biology» Interested in:» Solving biological problems with computers and algorithms > e.g. drug discovery» Cryptocurrencies and blockchain technology for scientific development» Website: www.cgoliver.com» Email: carlos.gonzalezoliver@mail.mcgill.ca» Office: Trottier 3140 3

Housekeeping» Office Hour Schedule is on the webpage as a Google Calendar: http://www.cs.mcgill.ca/ ~jeromew/comp250.html» Office hours will be held in TR 3090» Assignment 1 should be out by January 29th.» IMPORTANT: all correspondence regarding the course should be sent to: cs250@cs.mcgill.ca» Otherwise, your email will likely not get read. 4

Java vs other programming languages Basic syntax very similar to C, C++ Fully object-oriented: all code and data is within a class Java handles memory management: no need to allocate or free memory! No pointers, no segmentation faults!! Easy to learn and use Execution time slightly slower than C or C++ 5

Installing Java» Install the latest Java Development Kit (JDK) for your operating system.» http://www.oracle.com/technetwork/java/ javase/downloads/jdk8- downloads-2133151.html» Recommendation: attend OH before A1 is out to make sure you are ready to work with Java 6

Hello World! [Downey Ch 2] /* This programs prints a welcoming statement */ public class Welcome { // Every executable class have to contain a method called main like below // When the class is executed, main is the first method to be called public static void main(string args[]) { } } System.out.println( Welcome to Java! ); System.out.println( This is easy! ); 1) Compile Welcome.java 2) Run the program Output: Welcome to Java! This is easy! File: Welcome.java 7

Programming cycle in Java [Downey Ch 1] Run-time error: Program stops with error message (Exception) OR Programs does not produce the expected output Java source code Java byte-code Code execution Compilation error, due to incorrect syntax Java compiler Notes on java byte-code: Java Virtual Machine (JVM): Interprets Java byte-code Advantages: - Byte-code is platform independent - Very important for internet! Disadvantage: - Byte-code has to be interpreted by the JVM so it 8 runs slightly slower

How do we execute these instructions?» Two major options» Text editor + Command Line/Terminal (my preferred method)» Integrated Development Environment (IDE) 9

Text editor + Command Line» Step 1:» Write a class in a.java file using a PLAINTEXT text editor (vim, sublime, etc).» Step 2» Compile the source.java file using javac» javac HelloWorld.java» Step 3» Execute the Byte code (.class)» java HelloWorld 10

Files of Interest» Source files contain the Java code you write.» Always have suffix.java» Have the same name as the class in th» These are the ONLY files we want when submitting assignments (unless otherwise stated)» Class files contain Java byte code» Always have suffix.class» Generated by the compiler 11

Integrated Development Environment IDE: Program that facilitates writing code, compiling it, running it, and debugging it. Recommended IDE: Eclipse Freely available at http://www.eclipse.org/downloads/index.php You also need to install a Java Runtime Environment (JRE), from the same URL. Runs on all OS: Windows, Mac, Linux, etc. Installed on all machines in Trottier Guide by Caitrin Armstrong from last semester on using Eclipse: http://www.cim.mcgill.ca/~langer/ 250/eclipse_tutorial.pdf 12

How to install Eclipse https://youtu.be/v04ejdvsijg 13

Hello World in Eclipse 14

Eclipse Disclaimer» Eclipse sometimes generates extra files and inserts extra statements in your code.» E.g. package declarations» We DO NOT accept these in assignment submissions (unless otherwise stated) 15

IDE vs Command Line: Pros and Cons» IDE» Pros» Automates compilation, syntax checking» Debugging tools» Cons» Too automatic (unnecessary modifications)» Many more options than necessary for us 16

IDE vs Command Line: Pros and Cons» Command Line» Pros» Lightweight and simple» No unnecessary features» Often no need to install» Cons» A bit more manual work 17

Trottier Workstations» We recommend you use computers on Trottier 3rd floor to test your code.» Step 1 - get an account» Create a SOCS (School of Computer Science) account» Option 1» If you are on campus you can do it on this link: http://newuser.cs.mcgill.ca/newuser/» Option 2» Directly on any computer in Trottier 3rd floor. Follow instructions on the screen 18

Trottier Workstations» Step 2 - log in to your account» Option 1: run your code from Trottier» Log in normally and test» Option 2: remotely (from home or anywhere around the globe) a.k.a ssh» https://www.cs.mcgill.ca/docs/accounts» In your terminal (MacOS or Linux):» ssh username@mimi.cs.mcgill.ca» Windows, install PuTTy http://www.putty.org/ 19