Java Looking at our first console application in Eclipse

Slides:



Advertisements
Similar presentations
Introduction to Programming Java Lab 1: My First Program 11 January JavaLab1.ppt Ping Brennan
Advertisements

Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
©2004 Brooks/Cole Chapter 1: Getting Started Sections Covered: 1.1Introduction to Programming 1.2Constructing a Java Program 1.3The print() and println()
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,
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
LESSON 2 CREATING A JAVA APPLICATION JAVA PROGRAMMING Compiled By: Edwin O. Okech [Tutor, Amoud University]
1 v1.6 08/02/2006 Overview of Eclipse Lectures 1.Overview 2.Installing and Running 3.Building and Running Java Classes 4.Refactoring 5.Debugging 6.Testing.
Using Eclipse. What is Eclipse? The Eclipse Platform is an open source IDE (Integrated Development Environment), created by IBM for developing Java programs.
© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Appendix E The EZJava.
Copyright © Curt Hill Java Looking at our first console application in Eclipse.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
Introduction to Java Programming with Forte Y. Daniel Liang.
Introduction to Eclipse CSC 216 Lecture 3 Ed Gehringer Using (with permission) slides developed by— Dwight Deugo Nesa Matic
Copyright © Curt Hill First Window Builder Program Easy GUIs in Eclipse.
Unit 1: Java and Eclipse The Eclipse Development Environment.
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
Anatomy of a Java Program. AnotherQuote.java 1 /** A basic java program 2 * 3 Nancy Harris, James Madison University 4 V1 6/2010.
3. Methods. Programming Paradigms Procedural Programming ‘Imperative’ assignment used to create state, and procedures manipulate state. E.g., C, Assembly,
Java methods Methods break down large problems into smaller ones Your program may call the same method many times saves writing and maintaining same code.
CSI 3125, Preliminaries, page 1 Compiling the Program.
A brief introduction to javadoc and doxygen. What’s in a program file? 1. Comments 2. Code.
Eclipse Project. Installing Visit to download a copy for your home computerhttp:// –Get Release version 3.0 (or.
Creating a Java Application and Applet
Copyright © Curt Hill Simple I/O Input and Output using the System and Scanner Objects.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program.
Introduction to Java Programming, 4E Y. Daniel Liang.
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Eclipse.
Introduction to Java Import Scanner class to use in our program
The eclipse IDE IDE = “Integrated Development Environment”
More About Objects and Methods
The need for Programming Languages
Working with Java.
Tutorial 10 Programming with JavaScript
An Eclipse Plugin for Creating Windows Graphical User Interfaces
ATS Application Programming: Java Programming
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Documentation Generators
Console and GUI Programs
Eclipse Navigation & Usage.
CompSci 230 Software Construction
Intro to Java.
Introduction to javadoc
Predefined Dialog Boxes
Debugging with Eclipse
How to Run a Java Program
Java Intro.
Tonga Institute of Higher Education
Anatomy of a Java Program
Constructors, GUI’s(Using Swing) and ActionListner
Debugging Visual Basic Programs
Introduction to javadoc
Using Eclipse.
Fundamental OOP Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Java Programming with BlueJ Objectives
In this class, we will cover:
Running a Java Program using Blue Jay.
An Eclipse Plugin for Creating Windows Graphical User Interfaces
Methods/Functions.
Debugging with Eclipse
Workshop for Programming And Systems Management Teachers
Presentation transcript:

Java Looking at our first console application in Eclipse Copyright © 2004-2015 Curt Hill

A moment on paradigms Java is well suited for either the console or GUI paradigm A console program views the keyboard/screen as nearly a single device We both read and write to it using strings A GUI program has a WIMP interface: Windows Input Menus Pointer The console paradigm is easier for starters, but we will do both Copyright © 2004-2015 Curt Hill

Eclipse Eclipse is the Interactive Development Environment that we will use Originally developed by IBM Donated to public domain Now maintained by the Eclipse Foundation www.eclipse.org Copyright © 2004-2015 Curt Hill

Terminology for Eclipse Resource Things such as projects, directories and files Editor A window pane that allows changes to a resource, often Java code View A window pane that shows a resource Perspective A group of editors and views Copyright © 2004-2015 Curt Hill

Eclipse Construction steps Create new project Create new class Customize as needed Debug and run Copyright © 2004-2015 Curt Hill

Create new project Click File|New|Java Project Use the New Project dialog to set some initial parameters Specify the project name This will become a directory tree The project is an XML file of name: .project in the directory The screen shots follow Copyright © 2004-2015 Curt Hill

Create New Project Copyright © 2004-2015 Curt Hill

Enter Project Name Copyright © 2004-2015 Curt Hill

A usually skipped screen Copyright © 2004-2015 Curt Hill

Projects and Classes A project is just a tool to manage pieces We now have to add the pieces Each Java program is a class Any class might use other classes as well What we now do is add the main or root class to our project Copyright © 2004-2015 Curt Hill

Create new class Click File|New|Class This generates a new class This new class will be your program Use java.lang.Object as the ancestor class Specify a main method Click on the box Copyright © 2004-2015 Curt Hill

Add an initial class Copyright © 2004-2015 Curt Hill

Name the class Copyright © 2004-2015 Curt Hill

Specified names In the prior screen there were three things that were specified: Package Class name Inclusion of the main method via checkbox The package name is usually all lower case The class name usually starts with a capital letter and each subsequent word is capitalized: FirstCon Copyright © 2004-2015 Curt Hill

Generated Code Copyright © 2004-2015 Curt Hill

Customize as needed At this point we have a Java console program with proper form, which does nothing Now add the desired functionality Insert into main: System.out.println(“Hello world”); Java is case sensitive so System must start with a capital That doesn’t sound like much work It will get worse Copyright © 2004-2015 Curt Hill

Customized Copyright © 2004-2015 Curt Hill

Debug and run Click the run button or use menu Run|Run Run time properties are displayed Specify the new class name Search may be easiest Console output will appear in the bottom pane First the command line Next the program output Copyright © 2004-2015 Curt Hill

Start Run Copyright © 2004-2015 Curt Hill

Run Copyright © 2004-2015 Curt Hill

Code package firstcon; public class FirstCon { /** * @param args */ public static void main (String[] args) { // TODO Auto-generated method stub System.out.println("Hello World"); } } Copyright © 2004-2015 Curt Hill

Comments A comment explains things for people /* and */ // Ignored by Java /* and */ Enclose multiline comments // Makes the rest of the line a comment Documentation uses special comments Program: Javadoc Copyright © 2004-2015 Curt Hill

Class Declaration public class FirstCon { Objects in Java are called Classes A class binds together variables and methods This class is named FirstCon Its visibility is public A private class in this case could not be executed Copyright © 2004-2015 Curt Hill

Classes and files A file is the compilation unit It must have an extension .java Each file must have one and only one public class The file name must match the public class name Even case, which may be a problem on MS Operating Systems Most of these issues are handled by Eclipse without our intervention Copyright © 2004-2015 Curt Hill

Compilation Units Public class names must match file name Other private or friendly classes may be present in the file Each class will have its own object (.CLASS) file after it is compiled Copyright © 2004-2015 Curt Hill

Main Function Most classes have both variables and methods Every application must have a method called main, which is where execution starts Main’s parameter is a string array Command line parameters Often, in a console program most of the work occurs in the main method Copyright © 2004-2015 Curt Hill

Main function public static void main(String args[ ]) { System.out.println("Hello World!"); } // end of main void indicates main returns nothing It is public Accessible to system Copyright © 2004-2015 Curt Hill

Main function It is static This main function has just one statement A static function has limited access to class data Can be called without having a class instance This main function has just one statement We will cover static more later Copyright © 2004-2015 Curt Hill

Writing to the console System.out.println("Hello world"); System is an instance of a class that contains numerous predefined classes and methods out is an output stream class with methods print and println Copyright © 2004-2015 Curt Hill

print and println Overloaded method names Accept one parameter There is a version for almost every parameter type Copyright © 2004-2015 Curt Hill

Classes and objects Sometimes these two terms are used interchangably A class is a type Defines possible values and actions An object is an instance of a class Example A person name would be a class “Curt Hill” would be an object, an instance of a class Copyright © 2004-2015 Curt Hill

Finally There are some other details that need to be considered: Handing in programs These will be covered in a subsequent presentation Copyright © 2004-2015 Curt Hill