JAVA BASICS. Why Java for this Project? Its open source - FREE Java has tools that work well with rdf and xml –Jena, Jdom, Saxon Can be run on UNIX,Windows,LINUX,etc.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 4 Writing Java Applications, Java Development Tools.
Advertisements

Introduction to Java 2 Programming Lecture 3 Writing Java Applications, Java Development Tools.
A Programmer's Introduction to Java - from a S/370 user (c) IDMS/SQL News
ANT: Another Nice Tool Ali Beyad October 1, 2003.
Lab#1 (14/3/1431h) Introduction To java programming cs425
PACKAGES. PACKAGES IN JAVA A package is a collection of related classes and interfaces in Java Packages help in logical grouping of classes and interfaces.
1 Introduction to Java and Applet. 2 Download Java Compiler (1)
Introduction to Object- Oriented Programming with Java Spring Semester 2003 Paul Krause.
Introduction to Java Programming, 4E
Unit2: Object-oriented programming Getting started with Java Jin Sa.
Guide To UNIX Using Linux Third Edition
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Developing User Interfaces (DUI) Chris North cs3724: HCI.
Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
Introduction to Java Programming with JBuilder 4
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Java 程序设计 Java Programming Fall, Contents for Today Java Program Structure  How to Compile a Java Program  How to Run a Java Program Environment.
Java and C++, The Difference An introduction Unit - 00.
(C) 2010 Pearson Education, Inc. All rights reserved.  Java programs normally go through five phases  edit  compile  load  verify  execute.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Introduction to Java Programming. History F James Gosling and Sun Microsystems F Oak F Java, May 20, 1995, Sun World F HotJava –The first Java-enabled.
© 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.
1 Part I : Chapter 01 Introduction to Java Programming.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Java Applets. 2 Introduction to Java Applet Programs  Applications are stand alone programs executed with Java interpreter executed with Java interpreter.
OOP (Java): Simple/ OOP (Java) Objectives – –give some simple examples of Java applications and one applet 2. Simple Java Programs Semester.
Copyright © Curt Hill Java Looking at our first console application in Eclipse.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Introduction to Java Programming with Forte Y. Daniel Liang.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Applets. What is an applet? Why create applets instead of applications? – Applets are Java programs that can be embedded in an HTML document – In contrast,
Introduction to Java Programming. Introduction Course Objectives Organization of the Book.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Java Programming Lecture 1 Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University
Ant Presentation by: Bart Taylor. What is Ant? The simple definition: A Java-based build tool The Official Definition: “Apache Ant is a Java-based build.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
23-October-2002cse JavaIntro © 2002 University of Washington1 Intro to Java CSE 413, Autumn 2002 Programming Languages
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
CS170 ygao JAVA, C4Slide 1. CS170 ygao JAVA, C4Slide 2.
Java -- A very Hot Object- Oriented Language Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Creating a Java Application and Applet
Packages. Access Specifications Public Available anywhere (public keyword) Only one public class per file allowed Protected Available in subclasses, and.
1 Chapter 6 Programming with Objects and Classes F OO Programming Concepts F Creating Objects and Object Reference Variables –Differences between primitive.
Java Package Advantage of Java Package
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 15: Java Basics Fundamentals of Web Programming.
Features of JAVA PLATFORM INDEPENDENT LANGUAGE JAVA RUNTIME ENVIRONMENT (JRE) JAVA VIRTUAL MACHINE (JVM) JAVA APP BYTE CODE JAVA RUNTIME ENVIRONMENT.
Introduction to Java Programming, 4E Y. Daniel Liang.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
JAVA MULTIPLE CHOICE QUESTION.
Object-Oriented Programming with Java
Java Basics Packages.
Java Applets.
Object-Oriented Software Engineering
Applying OO Concepts Using Java
Java Looking at our first console application in Eclipse
Classes 5/5 May 14, 2019 ICS102: Classes 5/5.
Chap 1. Getting Started Objectives
Chap 4. Programming Fundamentals
Interfaces,Packages and Threads
Presentation transcript:

JAVA BASICS

Why Java for this Project? Its open source - FREE Java has tools that work well with rdf and xml –Jena, Jdom, Saxon Can be run on UNIX,Windows,LINUX,etc GUI/Applet capabilities Igor’s application WE NEED TO LEARN IT ANYWAY! WE NEED TO LEARN IT ANYWAY!

How to run JDK – Java Development Kit –Basic compiler, linker, and libraries IDE – Integrated Development Environment –NetBeans – netbeans.org

How to run Types of files –.java – source code –.class – executable code –.jar (java archive) - bundle of multiple files Tutorial - ics/index.html ics/index.html ics/index.html –Packages – groups of related classes in a directory

How to run Applications –javac – java compiler Commandline - javac classname.java –java – executes application Commandline - java classname –Jikes – faster version of java command Commandline – jikes classname

How to run Environment Variables –Path – searches computer for executeable –Classpath – searches computer for classes that need to be used

How to run Applets – java applications that are embedded in html and run in a browser –Appletviewer – shows sample in browser Commandline – appletviewer appletpage.html

How to run Make – (if you are sick of javac and java) –Defines which components go together to make a program. –Defines how to "put the pieces together". –Keeps track of dependencies among components. –Helps avoid doing unnecessary work and forgetting to do necessary work

How to run Makefile – example default: javac Animal.java note: there is a tabspace in front of javac note: there is a tabspace in front of javac Commandline – make - This compiles the file called Animal.java

How to run Makefile – example Tiger.java: Tiger.java Animal.class javac Tiger.java Animal.class must exist for tiger.java to compile Animal.class must exist for tiger.java to compile Commandline – make tiger.java

How to run Makefile – example all: Tiger Animal Tiger: javac Tiger.java Animal: javac Animal.java Commandline – make all “all” triggers both Tiger and Animal to compile

How to run ANT –Similar to make in that it stores in a project –Apache application –See handout

Java Programming Import –“includes” a predefined java package that will be used in a program –Statements made outside of the code –Package must be contained in a directory given in the classpath –* denotes search entire directory –Example Import java.applet.Applet; Public class BinarySearch extends JApplet { …}

Java Programming Important predefined java classes –Java.io.* - i/o files and streams –Java.awt.*,java.swing.* - GUI tools –Java.util.* - data structures –Java.applet.Applet – applets –Java.servlet.* - used for scripts, tomcat and other interactive servers –Java.sql.* - used for sql handling –Java.net.* - network apps

Java Programming Package – used for user defined packages –Command used when wanting to include the class in a package –Used outside class declaration –Example package john.harney.example; Public class whatever {…} - Assuming the current directory is default, this statement will place the whatever.class in the default/john/harney/example directory - Commandline – javac –d. Whatever.java

Java Programming General Format /*import and package statements here*/ public/private/protected class classname{ … Member variables Constructors Methods (member functions) …} -File must be saved as “classname.java” -Main (like c++) is executeable for an application (public static void main(args)) -Class must be compiled in order to be used by another class

Java Programming Executable example (Welcome3.java) public class Welcome3 { // main method begins execution of Java application // main method begins execution of Java application public static void main( String args[] ) public static void main( String args[] ) { System.out.println( "Welcome\nto\nJava\nProgramming!" ); System.out.println( "Welcome\nto\nJava\nProgramming!" ); } // end method main } // end method main } // end class Welcome3

Circle.java example (Java vs C++) –Class Header Instead of: class Circle : public Point There is: public class Circle extends Point;

Java Programming Circle.java example (Java vs C++) –Member variables Instead of: private: double radius; There is: private double radius;

Java Programming Circle.java example (Java vs C++) –Constructors Instead of: Circle(int x,int y, double radiusValue); There is: public circle(int x,int y, double radiusValue); Note: “public” denotes that this may be constructed outside of the class declaration

Java Programming Circle.java example (Java vs C++) –Member functions (methods) Instead of: double getRadius() { return radius; } There is: public double getRadius() { return radius; } Note: “public” denotes that this may called outside of the class

Java Programming Circle.java example //assume the compiler can find circle.class Import javax.swing.JOptionPane; //allows GUI input public class CircleImplement { // main method begins execution of Java application // main method begins execution of Java application public static void main( String args[] ) public static void main( String args[] ) { Circle circ = new Circle(2,2,4.0); //constructor Circle circ = new Circle(2,2,4.0); //constructor double rad = circ.getRadius();//calls to method getRadius double rad = circ.getRadius();//calls to method getRadius JOptionPane.showMessageDialog(null,rad); //prints radius JOptionPane.showMessageDialog(null,rad); //prints radius } // end method main } // end method main } // end class Welcome3

Java Programming Other notable differences between Java and C++ –Strings are immutable –No global variables –Memory allocation is not needed (ie no pointers) –Garbage Collection –No operator overloading

Javadoc Javadoc – gives info about a source file –Commandline – javadoc class.java –Gives html documentation on the variables, methods, inheritence, other comments, etc. –Format – see handout

JDOM JDOM – java class that enables XML construction and parsing –Handout

Saxon Saxon - dex.html –Supports XSLT,XPath,XQuery –Can be used with JDOM –Commandline java classname sourcexml > destinationxml