CS 4244: Internet Programming Network Programming in Java 1.0.

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.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
How to Create a Java program CS115 Fall George Koutsogiannakis.
1 Java Networking – Part I CS , Spring 2008/9.
Programming Applets How do Applets work ? This is an HTML page This is the applet’s code It has a link to an applet.
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
Networking Support In Java 2 Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
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.
Introduction to Remote Method Invocation (RMI)
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
Lab 1 Instructor: Jolanta Soltis.
Introduction to Java.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
CS0007: Introduction to Computer Programming Setting Up Java.
public static void main (String[] args)
Java Security Updated May Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security.
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
SOCKET PROGRAMMING. Client/Server Communication At a basic level, network-based systems consist of a server, client, and a media for communication as.
Misc. Java Alittle more network programming & Using jar files to share your work.
LESSON 2 CREATING A JAVA APPLICATION JAVA PROGRAMMING Compiled By: Edwin O. Okech [Tutor, Amoud University]
NET0183 Networks and Communications Lecture 31 The Socket API 8/25/20091 NET0183 Networks and Communications by Dr Andy Brooks Lecture powerpoints from.
(C) 2010 Pearson Education, Inc. All rights reserved.  Java programs normally go through five phases  edit  compile  load  verify  execute.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
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.
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.
15 - RMI. Java RMI Architecture Example Deployment RMI is a part of J2SE (standard edition), but is used by J2EE) A J2EE server is not nessesary for using.
UCSC All rights reserved. No part of this material may be reproduced and sold. 1 IT1202-Fundamentals Of Programming (Using JAVA) Interacting with.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Java Introduction to JNI Prepared by Humaira Siddiqui.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
CIS 644 Aug. 25, 1999 tour of Java. First … about the media lectures… we are experimenting with the media format please give feedback.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
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
JAVA SECURITY BASIC NETWORKING MULTITHREATING Deniz HASTORUN
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Object Oriented Programming Lecture 3. Introduction  In discussing Java, some items need to be clarified  The Java programming language  The Java virtual.
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.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
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.
CS Software Studio Java Lab 1 Meng-Ting Wang PLLAB, Computer Science Department, National Tsing-Hua University.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
Java Programming: Advanced Topics 1 Networking Programming Chapter 11.
Computer Science 101 Spring 2000 Section E8TBA Registration Code 1693 Dr. Christopher Vickery.
CORBA_1/001 Department of Computer Science Southern Illinois University Edwardsville Spring, 2010 Dr. Hiroshi Fujinoki CORBA:
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object.
Java Remote Method Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Networking A network represents interconnection of computers that is capable.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
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.
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
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.
RMI1 Remote Method Invocation Adapted from “Core Java 2” by Cay Horstmann.
Network Programming. These days almost all devices.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
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.
7 Class documentation and libraries
Programming without BlueJ Week 12
Chap 1. Getting Started Objectives
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:

CS 4244: Internet Programming Network Programming in Java 1.0

Standard Java files source files: *.java Java source files contain the source code in readable form, as typed in by the programmer. class files: *.class Java class files contain byte code (a machine readable version of the class). They are generated by the compiler from the source file.

source file class file editor compiler (javac) virtual machine (java) The edit-compile-execute cycle

Editing A file can be edited in any text editor Notepad, emacs, PFE,... careful with using Word: by default, Word does not save in text format Make sure to save before compiling!

Command line invocation compilation and execution of Java in JDK are done from a command line On Microsoft systems: DOS shell On Unix: Unix shell Must make sure that the commands for compiler and runtime are in the command path.

Compiling Name of the JDK compiler: javac To invoke: javac compiles and all classes it depends on Example: cd C:\bluej\zuul javac Game.java

Error messages C:\bluej\zuul> javac Game.java Game.java:22: ';' expected. private Parser parser ^ 1 error C:\bluej\zuul> The programmer has to open the file in the editor, find the line number, fix the error and recompile.

Execution C:\bluej\zuul> java Game “java” starts the Java virtual machine. The named class is loaded and execution is started. Other classes are loaded as needed. Only possible if class has been compiled.

Problem: Execute what? If we try: C:\bluej\zuul> java Game.java Exception in thread "main" java.lang.NoSuchMethodError: main The problem: how does the system know which method to execute?

The main method The answer: The java system always executes a method called main with a certain signature: public static void main(String[] args) {... } For this to work, such a method must exist!

The main method (2) “main” must exist “main” must be public “main” must be static (class method) “main” must have a String array parameter Only “main” can be invoked

Main method - example public static void main(String[] args) { Game game = new Game(); game.play(); } The main method should create an object call the first method

Java platform Comprises of various packages, each containing related classes Some key packages are java.util java.io java.lang java.net …

Java Network Programming Main package is java.net Contains various classes including Socket DatagramPacket URLConnection HTTPURLConnection...

Socket class Socket s = new Socket(hostname, port); Java abstraction of network socket Used to connect to machine/ip address with specified port number Depending on port number you connect on, you need to send more information

ServerSocket class ServerSocket srv = new ServerSocket(port) Used to create a Server socket Key method here is accept() of type Socket Makes server wait for connection and opens socket on valid request