Presentation is loading. Please wait.

Presentation is loading. Please wait.

Clement Allen, PhD Florida A&M University SUMMER 2006.

Similar presentations


Presentation on theme: "Clement Allen, PhD Florida A&M University SUMMER 2006."— Presentation transcript:

1 Clement Allen, PhD Florida A&M University SUMMER 2006

2 http://www.cis.famu.edu/~cisjava

3

4

5

6 (SAMPLE)

7 Introduction to JAVA History of Java Why all the fuss? Our first Java program Compiling and Executing a Java Program ~ ~ if else ~ ~ system.out

8 Introduction to JAVA History What is JAVA and why the big deal? “A simple, object-oriented, multi-threaded, portable, platform-independent, secure programming environment for creating applications and smaller programs called applets” SUN engineers embark on a mission to develop a platform independent language that could be used to program consumer appliances

9 Simple Stripped-down version of C/C++ minus all the confusing, troublesome features of C/C++ Object-oriented Promotes good software engineering. Facilitates reuse. Multithreaded Programs can handle many operations simultaneously

10 Platform-independent Executable code is bytecode that can run run any machine. Compile once, run everywhere. Secure Applets run in a protected space Portable Works the same on all machines. Write once, run anywhere.

11 JAVA Fundamentals The two types of Java programs Applets Applications A program that is executed within a Web browser All other programs; a program executed from the command line.

12 Use your favorite editor to create the source code $ emacs Hello.java / / Program : Hello // Date : 8/27/97 // Date Modified : // Authors : Clement Allen // Description : Our first application public class Hello { // Defines the application called Hello public static void main (String args[ ]) { // Every application has main System.out.println("Hello!"); // This prints the word Hello } // end main } // end Hello

13 Compile source code $ javac Hello.java Execute the program $ java Hello Hello creates a file called Hello.class Run Program

14 import javax.swing.*; public class Welcome { // Defines an application called Welcome // begin the execution public static void main(String args[ ] ) { // display a window JOptionPane.showMessageDialog(null,"Welcome to COP3060!!!"); // terminates the application System.exit(0); }

15 Compile source code $ javac Welcome.java Execute the program $ java Welcome creates a file called Welcome.class Run Program

16 Eclipse is an open source IDE (Integrated Development Environment) for developing applications in Java, C/C++, HTML, Cobol, Perl, etc. The official Eclipse web site (eclipse.org) says, “Eclipse is a kind of universal tool platform -- an open extensible IDE for anything and nothing in particular.” Java Development with Eclipse

17 Provides a consistent feature set on most platforms Supports more than just Java or any single language Open source and free, yet fully supported Truly extensible and configurable Industrial strength Eclipse: Java Development with Eclipse

18 Start Eclipse by Double-clicking on the icon that appears on your desktop. The welcome screen will appear.

19 From this screen you can get an Overview of Eclipse, Tutorials, and Code Samples.

20 Each window is called a View. A collection of views is called a Perspective. There is a Java Perspective, Debug Perspective, C++ Perspective, etc.

21 To switch to a Perspective, go to Window -> Open Perspective…Then choose the Perspective you want. In this case, it is the Java Perspective.

22 To create a Java program, first create a Project that will contain your source code: File -> New -> Project -> Java Project

23 Give your project a name, in this case the project is Lab1. Choose Next and then Finish

24 You will see a folder called Lab1 in the Package Explorer View.

25 To create a Java program, Choose New -> Other -> Class.

26 Give your class a name, in the case Hello. Choose Finish.

27 You will see the the Class in the Package Explorer View, and an Editor View appears where you will enter the code.

28 Type in the code for Hello.

29 To save, Right-click on the editor, choose Save.

30 To save, Right-click on the editor, choose Run As -> Java Application.

31 The output will appear in the Console View.


Download ppt "Clement Allen, PhD Florida A&M University SUMMER 2006."

Similar presentations


Ads by Google