Programming without BlueJ Week 12

Slides:



Advertisements
Similar presentations
Using Java without BlueJ BlueJ projects A BlueJ project is stored in a directory on disk. A BlueJ package is stored in several different files.
Advertisements

Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
CPSC150 Fall 2008 Dr. L. Lambert. CPSC150 Overview Syllabus Use Textbook, ask questions, extra thorough, I will post sections covered All information.
How do we make our Welcome.java program do something? The java in our Welcome.java file won’t do anything by itself. We need to tell the computer to execute.
CS2200 Software Development Lecture 2: Java Program Development Lecturer: Adrian O’Riordan Course Webpage:
How to Create a Java program CS115 Fall George Koutsogiannakis.
How do we make our HelloTester.java program do something? The java in our HelloTester.java file won’t do anything by itself. We need to tell the computer.
Java Programming Working with TextPad. Using TextPad to Work with Java This text editor is designed for working with Java You can download a trial version.
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
Using Java without BlueJ Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling BlueJ projects A BlueJ.
Using Java without BlueJ Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling BlueJ projects A BlueJ.
Using Java without BlueJ
Introduction to Java.
CS0007: Introduction to Computer Programming Setting Up Java.
Marlene Galea.  The JDK (Java Development Kit)  An IDE (Integrated Development Environment) ◦ Different IDEs include:  JCreator  NetBeans  BlueJ.
Java PAL.  Contains the development kit and the runtime environment ( aka the Java Virtual Machine )  Download Link:
public static void main (String[] args)
IB Computer Science II Paul Bui
Introduction to Java Tonga Institute of Higher Education.
(C) 2010 Pearson Education, Inc. All rights reserved.  Java programs normally go through five phases  edit  compile  load  verify  execute.
Basics Programming Concepts. Basics A computer program is a set of instructions to tell a computer what to do Machine language = circuit level language.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
1.  At the end of this slide, student can:  Explore tools, features, properties and interface of the Textpad.  Creating a new project.  Open and run.
UCSC All rights reserved. No part of this material may be reproduced and sold. 1 IT1202-Fundamentals Of Programming (Using JAVA) Interacting with.
FRST JAVA PROGRAM. Getting Started with Java Programming A Simple Java Application Compiling Programs Executing Applications.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science.
1 CSC204 – Programming I Lecture 2 Intro to OOP with Java.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
POS 406 Java Technology And Beginning Java Code
COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Preliminaries CS 310: Object-oriented Programming Java API.
4-Nov-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic 1: The Java Environment Maj Joel.
EIE375 BlueJ: Getting Started Dr Lawrence Cheung.
22-July-2002cse142-13B-Development © 2002 University of Washington1 Development Tools CSE 142, Summer 2002 Computer Programming 1
”Java and JMLfor Dummies” The Java source code is written in a text file using your favourite editor (Notepad) and is saved with extension.java. Be careful.
CS 4244: Internet Programming Network Programming in Java 1.0.
Java Programming, Second Edition Appendix A Working with Java SDK 1.4.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
1. An Introduction A Programming Language A Technology Java Development Kit Java API One Language: Three Editions Standard Edition Enterprise Edition.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
CPRG 215 Introduction to Object-Oriented Programming with Java Module 1-Introduction to Java Topic 1.3 Write Your First Java Program Produced by Harvey.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
Objects First With Java A Practical Introduction Using BlueJ Using Java without BlueJ 1.0.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Using Java without BlueJ BlueJ projects A BlueJ project is stored in a directory on disk. A BlueJ package is stored in several different files.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
CS-140 Dick Steflik Lecture 3. Java C++ Interpreted optimized for the internet Runs on virtual ized machine Derived from C++ Good object model Widely.
CS210 Intermediate Computing with Data Structures (Java)
Lecture 1b- Introduction
7 Class documentation and libraries
Object-Oriented Programming Using Java
GC101 Introduction to computer and program
Running Programs & IDEs Reference: COS240 Syllabus
Compiling and Running a Java Program
A Short DOS Presentation
CompSci 230 Software Construction
Introduction to Java Dept. Business Computing University of Winnipeg
Java Intro III.1 (Fr Feb 23).
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Hands-on Introduction to JAVA
Java Intro.
IB Computer Science II Paul Bui
Road to Object Oriented Programming
Review of Previous Lesson
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
Presentation transcript:

Programming without BlueJ Week 12

CONCEPTS COVERED THIS WEEK Programming without BlueJ CONCEPTS COVERED THIS WEEK Running Java without BlueJ The main Method

The BlueJ directory structure Programming with BlueJ The BlueJ directory structure project: clock-display package.bluej ClockDisplay.java ClockDisplay.class ClockDisplay.ctxt NumberDisplay.java NumberDisplay.class NumberDisplay.ctxt ClockDisplay NumberDisplay look at package in BlueJ then look at directory compare files in directory to classes in package

The BlueJ file structure Programming with BlueJ The BlueJ file structure package.bluej Stores BlueJ project details ClassName.ctxt BlueJ class context file ClassName.java Java source code file ClassName.class Java bytecode file look at package in BlueJ then look at directory compare files in directory to classes in package

Programming without BlueJ Standard Java Files ClassName.java Java source files contain the source code in readable form, as typed in by the programmer. ClassName.class Java class files contain bytecode (a machine readable version of the class). They are generated by the compiler from the source file. look at package in BlueJ then look at directory compare files in directory to classes in package

Standard Java Edit-Compile-Run Cycle Programming without BlueJ Standard Java Edit-Compile-Run Cycle 011010 110101 1001 10 source file class file 011010 110101 010001 1 1 1 0111 0110110 look at package in BlueJ then look at directory compare files in directory to classes in package compiler (javac) editor virtual machine (java)

Editing Java Source Files Programming without BlueJ Editing Java Source Files A Java file can be edited using any text editor e.g. Notepad Careful with using Word as, by default, Word does not save in text format Be sure to save changes before compiling! look at package in BlueJ then look at directory compare files in directory to classes in package

Command Line Invocation Programming without BlueJ Command Line Invocation Compilation and execution of Java in JDK are done from a command line. Windows: DOS shell, i.e. Command Prompt: Ensure that the directory for the Java compiler (javac) and Java runtime (java) is set in the command path e.g. set path=C:\Program Files (x86)\Java\jdk1.6.0_33\bin look at package in BlueJ then look at directory compare files in directory to classes in package

Programming without BlueJ Java Compilation The name of the JDK compiler is javac To compile a Java class definition: javac <source name> javac compiles the source file as well as all other classes the source file depends upon. Example usage of javac: X:\>cd My Documents\Java\Picture X:\My Documents\Java\Picture>javac Picture.java look at package in BlueJ then look at directory compare files in directory to classes in package

Java Compilation (Error Messages) Programming without BlueJ Java Compilation (Error Messages) Example usage of javac: X:\>cd My Documents\Java\Picture X:\My Documents\Java\Picture>javac Picture.java Picture.java:14: ';' expected. private square wall ^ 1 error X:\My Documents\Java\Picture> look at package in BlueJ then look at directory compare files in directory to classes in package The programmer has to open the Java file in the editor, find the line number, fix the error and recompile.

Java Program Execution Programming without BlueJ Java Program Execution Example usage of java: X:\My Documents\Java\Picture>java Picture “java” starts the Java virtual machine (JVM). The named class is loaded and execution is started. Other classes are loaded as needed. Only possible if class has been compiled. look at package in BlueJ then look at directory compare files in directory to classes in package

Programming without BlueJ Java Program Execution – Problem: Execute What? Example usage of java: X:\My Documents\Java\Picture>java Picture Exception in thread "main" java.lang.NoSuchMethodError: main How does the system know which of the methods of the class to execute? look at package in BlueJ then look at directory compare files in directory to classes in package

Java Program Execution – The Main Method Programming without BlueJ Java Program Execution – The Main Method Example usage of javac: X:\My Documents\Java\Picture>java Picture Exception in thread "main" java.lang.NoSuchMethodError: main The solution: The Java system always executes a class method called main with a specific signature. look at package in BlueJ then look at directory compare files in directory to classes in package

Java Program Execution – The Main Method Programming without BlueJ Java Program Execution – The Main Method Fixed signature for the main method: public static void main(String[] args) { ... } For this to work, a main method must exist in one (and only one) of the classes being called! It is possible to place all of an application’s code in a class with just a main method! But this is absolutely NOT RECOMMENDED! look at package in BlueJ then look at directory compare files in directory to classes in package

Java Program Execution – The Main Method Programming without BlueJ Java Program Execution – The Main Method Example of a main method in a class called Game: public static void main(String[] args) { Game game = new Game(); game.play(); } look at package in BlueJ then look at directory compare files in directory to classes in package In general the main method should ONLY create an object call the first method

Creating a Java program Writing the Java code Any editor (such as Notepad) can be used to write a Java program. However, most professional programmers use a software application called an Integrated Development Environment or IDE JCreator http://www.jcreator.com/