NDK Integration (JNI)

Size: px
Start display at page:

Download "NDK Integration (JNI)"

Transcription

1 NDK Integration (JNI) Lecture 5 Android Native Development Kit 25 March 2014 NDK NDK Integration (JNI), Lecture 5 1/34

2 Standard JNI Standard JNI Example Native Method Arguments Mapping of Types Operations on Strings Bibliography Keywords NDK NDK Integration (JNI), Lecture 5 2/34

3 Outline Standard JNI Standard JNI Example Native Method Arguments Mapping of Types Operations on Strings Bibliography Keywords NDK NDK Integration (JNI), Lecture 5 3/34

4 Standard JNI Java Native Interface (JNI) Native Programming Interface Allows Java code to interoperate with apps and libraries written in other programming languages When do we use JNI? Java library does not support platform-dependent features Use already existent library written in other language Time-critical code in a low level language (performance) NDK NDK Integration (JNI), Lecture 5 4/34

5 Standard JNI Two-way interface Allows Java apps to invoke native code and vice versa NDK NDK Integration (JNI), Lecture 5 5/34

6 Two-way Interface Support for two types of native code Native libraries Call functions from native libraries In the same way they call Java methods Native applications Embed a Java VM implementation into native apps Execute components written in Java e.g. C web browser executes applets in an embedded Java VM implementation NDK NDK Integration (JNI), Lecture 5 6/34

7 Implications of Using JNI Java apps are portable Runs on multiple platforms The native component will not run on multiple platforms Recompile the native code for the new platform Java is type-safe and secure C/C++ are not Misbehaving native code can affect the whole application Security checks when invoking native code Extra care when writing apps that use JNI Native methods in few classes Clean isolation between native code and Java app NDK NDK Integration (JNI), Lecture 5 7/34

8 Outline Standard JNI Standard JNI Example Native Method Arguments Mapping of Types Operations on Strings Bibliography Keywords NDK NDK Integration (JNI), Lecture 5 8/34

9 Hello World Example Simple Java app calling a C function to print Hello World 1. Create HelloWorld.java that declares the native method 2. Compile HelloWorld.java using javac => HelloWorld.class 3. Use javah -jni to create C header file (function prototype) => HelloWorld.h 4. Write C implementation on native method => HelloWorld.c 5. Compile C code into native library => libhelloworld.so / HelloWorld.dll 6. Run HelloWorld using java runtime interpreter The class and native library loaded at runtime NDK NDK Integration (JNI), Lecture 5 9/34

10 Hello World Example c l a s s HelloWorld { s t a t i c { System. l o a d L i b r a r y ( HelloWorld ) ; } p r i v a t e native void p r i n t ( ) ; p u b l i c s t a t i c void main ( S t r i n g [ ] a r g s ) { new HelloWorld ( ). p r i n t ( ) ; } } In the static initializer we load the native library The native library on disk is called libhelloworld.so or HelloWorld.dll Declare the print native method (native modifier) In main we instantiate the HelloWorld class and invoke print native method NDK NDK Integration (JNI), Lecture 5 10/34

11 Hello World Example Compile the Java source code javac HelloWorld.java Creates HelloWorld.class in the same directory Generate JNI-style header file using javah tool javah -jni HelloWorld Generates HelloWorld.h Includes prototype for Java_HelloWorld_print JNIEXPORT void JNICALL Java_HelloWorld_print (JNIEnv *, jobject); NDK NDK Integration (JNI), Lecture 5 11/34

12 Hello World Example #i n c l u d e < j n i. h> #i n c l u d e <s t d i o. h> #i n c l u d e HelloWorld. h JNIEXPORT void JNICALL J a v a H e l l o W o r l d p r i n t ( JNIEnv env, j o b j e c t o b j ) { p r i n t f ( H e l l o World! \ n ) ; return ; } Follow the prototype in the generated header file jni.h - needed for native code to call JNI functions NDK NDK Integration (JNI), Lecture 5 12/34

13 Hello World Example Compile C code and build native library Linux: gcc -I/java/include -I/java/include/linux -shared -o libhelloworld.so HelloWorld.c Windows: cl -IC:\java\include -IC:\java\include\win32 -MD -LD HelloWorld.c -FeHelloWorld.dll NDK NDK Integration (JNI), Lecture 5 13/34

14 Hello World Example Run java app java HelloWorld Before, set the native library path to the current directory java.lang.unsatisfiedlinkerror: no HelloWorld in library path at java.lang.runtime.loadlibrary(runtime.java) at java.lang.system.loadlibrary(system.java) at HelloWorld.main(HelloWorld.java) Linux: LD_LIBRARY_PATH=. export LD_LIBRARY_PATH Windows: library in the current dir or in a dir from PATH Or specify the native library path when running java java -Djava.library.path=. HelloWorld NDK NDK Integration (JNI), Lecture 5 14/34

15 Outline Standard JNI Standard JNI Example Native Method Arguments Mapping of Types Operations on Strings Bibliography Keywords NDK NDK Integration (JNI), Lecture 5 15/34

16 JNIEnv interface pointer Passed into each native method call as the first argument Valid only in the current thread (cannot be used by other threads) Points to a location that contains a pointer to a function table Each entry in the table points to a JNI function Native methods access data structures in the Java VM through JNI functions NDK NDK Integration (JNI), Lecture 5 16/34

17 JNIEnv interface pointer For C and C++ source files the syntax for calling JNI functions differs C code JNIEnv is a pointer to a JNINativeInterface structure Pointer needs to be dereferenced first JNI functions do not know the current JNI environment JNIEnv instance should be passed as the first argument to the function call e.g. return (*env)->newstringutf(env, "Hello!"); C++ code JNIEnv a C++ class JNI functions exposed as member functions JNI functions have access to the current JNI environment e.g. return env->newstringutf("hello!"); NDK NDK Integration (JNI), Lecture 5 17/34

18 Second Argument Second argument depends whether the method is static or instance Instance methods - can be called only on a class instance Static methods - can be called directly from a static context Both can be declared as native For instance native method Reference to the object on which the method is invoked (this in C++) e.g. jobject thisobject For static native method Reference to the class in which the method is defined e.g. jclass thisclass NDK NDK Integration (JNI), Lecture 5 18/34

19 Outline Standard JNI Standard JNI Example Native Method Arguments Mapping of Types Operations on Strings Bibliography Keywords NDK NDK Integration (JNI), Lecture 5 19/34

20 Mapping of Types JNI defines a set of C/C++ types corresponding to Java types Java types Primitive types: int, float, char Reference types: classes, instances, arrays The two types are treated differently by JNI int -> jint (32 bit integer) float -> jfloat (32 bit floating point number) NDK NDK Integration (JNI), Lecture 5 20/34

21 Primitive Types Java Type JNI Type C/C++ Type Size boolean jboolean unsigned char unsigned 8 bits byte jbyte char signed 8 bits char jchar unsigned short unsigned 16 bits short jshort short signed 16 bits int jint int signed 32 bits long jlong long long signed 64 bits float jfloat float 32 bits double jdouble double 64 bits NDK NDK Integration (JNI), Lecture 5 21/34

22 Objects Objects -> opaque references C pointer to internal data structures in the Java VM Objects accessed using JNI functions (JNIEnv interface pointer) e.g. GetStringUTFChars() function for accessing the contents of a string All JNI references have type jobject All reference types are subtypes of jobject Correspond to the most used types in Java jstring, jobjectarray, etc. NDK NDK Integration (JNI), Lecture 5 22/34

23 Reference Types Java Type java.lang.class java.lang. String java.lang.throwable other objects java.lang.object[] boolean[] byte[] char[] short[] int[] long[] float[] double[] other arrays Native Type jclass jstring jthrowable jobject jobjectarray jbooleanarray jbytearray jchararray jshortarray jintarray jlongarray jfloatarray jdoublearray jarray NDK NDK Integration (JNI), Lecture 5 23/34

24 Outline Standard JNI Standard JNI Example Native Method Arguments Mapping of Types Operations on Strings Bibliography Keywords NDK NDK Integration (JNI), Lecture 5 24/34

25 String Types String is a reference type in JNI (jstring) Cannot be used directly as native C strings Need to convert the Java string references into C strings and back No function to modify the contents of a Java string (immutable objects) JNI supports UTF-8 and UTF-16/Unicode encoded strings UTF-8 compatible with 7-bit ASCII UTF-8 strings terminated with \0 char UTF-16/Unicode - 16 bits, not zero-terminated Two sets of functions jstring is represented in Unicode in the VM NDK NDK Integration (JNI), Lecture 5 25/34

26 Convert C String to Java String NewStringUTF, NewString jstring javastring = (*env)->newstringutf(env, "Hello!"); Takes a C string, returns a Java string reference type If the VM cannot allocate memory Returns NULL OutOfMemoryError exception thrown in the VM Native code should not continue NDK NDK Integration (JNI), Lecture 5 26/34

27 GetStringUTFChars, GetStringChars Convert Java String to C String const jbyte* str = (*env)->getstringutfchars(env, javastring, &iscopy); const jchar* str = (*env)->getstringchars(env, javastring, &iscopy); iscopy JNI_TRUE - returned string is a copy of the chars in the original instance JNI_FALSE - returned string is a direct pointer to the original instance (pinned object in heap) Pass NULL if it s not important If the string contains only 7-bit ASCII chars you can use printf If the memory allocation fails it returns NULL, throws OutOfMemory exception NDK NDK Integration (JNI), Lecture 5 27/34

28 Release Strings Free memory occupied by the C string ReleaseStringUTFChars, ReleaseStringChars (*env)->releasestringutfchars(env, javastring, str); String should be released after it is used Avoid memory leaks Frees the copy or unpins the instance (copy or not) NDK NDK Integration (JNI), Lecture 5 28/34

29 Length and Copy in Buffer Get string length GetStringUTFLength/GetStringLength on the jstring Or strlen on the GetStringUTFChars result Copy string elements into a preallocated buffer (*env)->getstringutfregion(env, javastring, 0, len, buffer); start index and length length can be obtained with GetStringLength buffer is char[] No memory allocation, no out-of-memory checks NDK NDK Integration (JNI), Lecture 5 29/34

30 Critical Region GetStringCritical, ReleaseStringCritical Increase the probability to obtain a direct pointer to the string Critical Section between the calls Must not make blocking operations Must not allocate new objects in the Java VM Disable garbage collection when holding a direct pointer to a string Blocking operations or allocating objects may lead to deadlock No GetStringUTFCritical -> usually makes a copy of the string NDK NDK Integration (JNI), Lecture 5 30/34

31 Outline Standard JNI Standard JNI Example Native Method Arguments Mapping of Types Operations on Strings Bibliography Keywords NDK NDK Integration (JNI), Lecture 5 31/34

32 Bibliography material/jni.pdf guides/jni/spec/jnitoc.html guides/jni/spec/functions.html perf-jni.html Onur Cinar, Pro Android C++ with the NDK, Chapter 3 Sylvain Ratabouil, Android NDK, Beginner s Guide, Chapter 3 NDK NDK Integration (JNI), Lecture 5 32/34

33 Outline Standard JNI Standard JNI Example Native Method Arguments Mapping of Types Operations on Strings Bibliography Keywords NDK NDK Integration (JNI), Lecture 5 33/34

34 Jave Native Interface Two-way interface Native methods Interface pointer Static methods Instance methods Primitive types Reference types JNI functions Opaque reference Java string reference Conversion operations To be continued.. NDK NDK Integration (JNI), Lecture 5 34/34

VOL. 3, NO.10 Oct, 2012 ISSN 2079-8407 Journal of Emerging Trends in Computing and Information Sciences 2009-2012 CIS Journal. All rights reserved.

VOL. 3, NO.10 Oct, 2012 ISSN 2079-8407 Journal of Emerging Trends in Computing and Information Sciences 2009-2012 CIS Journal. All rights reserved. Java and C/C++ Interoperability: Java Integration to Windows Event Log 1 Aleksandar Bulajic, 2 Slobodan Jovanovic 1, 2 Faculty of Information Technology, Metropolitan University, 11000 Belgrade, Serbia

More information

Numerical Algorithms Group

Numerical Algorithms Group Title: Summary: Calling C Library Routines from Java Using the Java Native Interface This paper presents a technique for calling C library routines directly from Java, saving you the trouble of rewriting

More information

Programming CAN-based Fieldbus Systems using Java

Programming CAN-based Fieldbus Systems using Java Title Programming CAN-based Fieldbus Systems using Java Manuel Joaquim Pereira dos Santos, Ricardo José Caetano Loureiro Universidade de Aveiro, Aveiro, Portugal, Helmut Dispert Department of Computer

More information

Java/C++ integration: Writing native Java methods in natural C++

Java/C++ integration: Writing native Java methods in natural C++ Java/C++ integration: Writing native Java methods in natural C++ Per Bothner Brainfood Tom Tromey Red Hat Abstract 1.1 The Java Native Interface Native methods in

More information

Introduction to Native Android Development with NDK

Introduction to Native Android Development with NDK Introduction to Native Android Development with NDK Outline Motivation: case study of a real project Android Architecture Simplified Tool chain Diagram Adding 3 rd party modules Adding pdf and encrypted

More information

Crash Course in Java

Crash Course in Java Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is

More information

Wrapper Generator using Java Native Interface

Wrapper Generator using Java Native Interface Wrapper Generator using Java Native Interface Abstract V.S.Vairale 1 and K.N.Honwadkar 2 1 Department of Computer Engineering, AISSMS College of Engineering, Pune University, Pune, India vaishali.vairale@gmail.com

More information

Java Interview Questions and Answers

Java Interview Questions and Answers 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java

More information

Java Crash Course Part I

Java Crash Course Part I Java Crash Course Part I School of Business and Economics Institute of Information Systems HU-Berlin WS 2005 Sebastian Kolbe skolbe@wiwi.hu-berlin.de Overview (Short) introduction to the environment Linux

More information

CS 294-73 Software Engineering for Scientific Computing. http://www.cs.berkeley.edu/~colella/cs294. Lecture 25:Mixed Language Programming.

CS 294-73 Software Engineering for Scientific Computing. http://www.cs.berkeley.edu/~colella/cs294. Lecture 25:Mixed Language Programming. CS 294-73 Software Engineering for Scientific Computing http://www.cs.berkeley.edu/~colella/cs294 Lecture 25:Mixed Language Programming. Different languages Technical, historical, cultural differences

More information

Multithreading and Java Native Interface (JNI)!

Multithreading and Java Native Interface (JNI)! SERE 2013 Secure Android Programming: Best Practices for Data Safety & Reliability Multithreading and Java Native Interface (JNI) Rahul Murmuria, Prof. Angelos Stavrou rmurmuri@gmu.edu, astavrou@gmu.edu

More information

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in

More information

Introduction to Java

Introduction to Java Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

More information

Development_Setting. Step I: Create an Android Project

Development_Setting. Step I: Create an Android Project A step-by-step guide to setup developing and debugging environment in Eclipse for a Native Android Application. By Yu Lu (Referenced from two guides by MartinH) Jan, 2012 Development_Setting Step I: Create

More information

Reach 4 million Unity developers

Reach 4 million Unity developers Reach 4 million Unity developers with your Android library Vitaliy Zasadnyy Senior Unity Dev @ GetSocial Manager @ GDG Lviv Ankara Android Dev Days May 11-12, 2015 Why Unity? Daily Users 0 225 M 450 M

More information

AAC-ELD based Audio Communication on Android

AAC-ELD based Audio Communication on Android F R A U N H O F E R I N S T I T U T E F O R I N T E G R A T E D C I R C U I T S I I S APPLICATION BULLETIN AAC-ELD based Audio Communication on Android V2.8-25.07.2014 ABSTRACT This document is a developer

More information

An Overview of Java. overview-1

An Overview of Java. overview-1 An Overview of Java overview-1 Contents What is Java Major Java features Java virtual machine Java programming language Java class libraries (API) GUI Support in Java Networking and Threads in Java overview-2

More information

Pemrograman Dasar. Basic Elements Of Java

Pemrograman Dasar. Basic Elements Of Java Pemrograman Dasar Basic Elements Of Java Compiling and Running a Java Application 2 Portable Java Application 3 Java Platform Platform: hardware or software environment in which a program runs. Oracle

More information

Chapter 1 Java Program Design and Development

Chapter 1 Java Program Design and Development presentation slides for JAVA, JAVA, JAVA Object-Oriented Problem Solving Third Edition Ralph Morelli Ralph Walde Trinity College Hartford, CT published by Prentice Hall Java, Java, Java Object Oriented

More information

Java Programming Fundamentals

Java Programming Fundamentals Lecture 1 Part I Java Programming Fundamentals Topics in Quantitative Finance: Numerical Solutions of Partial Differential Equations Instructor: Iraj Kani Introduction to Java We start by making a few

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

Native code in Android Quad Detection

Native code in Android Quad Detection Native code in Android Quad Detection 21 July 2013 This document provides information on how to build and run native (C/C++) code in Android platform using Android NDK and then use its scope to auto capture

More information

The Decaffeinated Robot

The Decaffeinated Robot Developing on without Java Texas Linux Fest 2 April 2011 Overview for Why? architecture Decaffeinating for Why? architecture Decaffeinating for Why choose? Why? architecture Decaffeinating for Why choose?

More information

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 01 / 21 / 2014 Instructor: Michael Eckmann Today s Topics Introduction Homework assignment Review the syllabus Review the policies on academic dishonesty and improper

More information

Extending your Qt Android application using JNI

Extending your Qt Android application using JNI Extending your Qt Android alication using JNI Dev Days, 2014 Presented by BogDan Vatra Material based on Qt 5.3, created on November 13, 2014 Extending your alication using JNI Extending your alication

More information

Java from a C perspective. Plan

Java from a C perspective. Plan Java from a C perspective Cristian Bogdan 2D2052/ingint04 Plan Objectives and Book Packages and Classes Types and memory allocation Syntax and C-like Statements Object Orientation (minimal intro) Exceptions,

More information

public static void main(string[] args) { System.out.println("hello, world"); } }

public static void main(string[] args) { System.out.println(hello, world); } } Java in 21 minutes hello world basic data types classes & objects program structure constructors garbage collection I/O exceptions Strings Hello world import java.io.*; public class hello { public static

More information

The C Programming Language course syllabus associate level

The C Programming Language course syllabus associate level TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming

More information

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,

More information

JNI Java Native Interface. C and C++ Justification. Embedding C in Java. Generate JNI Header. HelloWorld.h

JNI Java Native Interface. C and C++ Justification. Embedding C in Java. Generate JNI Header. HelloWorld.h JNI Java Native Interface C and C++. JNI and STL Andrew W. Moore University of Cambridge (with thanks to Alastair R. Beresford and Bjarne Stroustrup) Michaelmas Term 2010 Java Native Interface (JNI) is

More information

CSE 452: Programming Languages. Acknowledgements. Contents. Java and its Evolution

CSE 452: Programming Languages. Acknowledgements. Contents. Java and its Evolution CSE 452: Programming Languages Java and its Evolution Acknowledgements Rajkumar Buyya 2 Contents Java Introduction Java Features How Java Differs from other OO languages Java and the World Wide Web Java

More information

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java

More information

Lecture 5: Java Fundamentals III

Lecture 5: Java Fundamentals III Lecture 5: Java Fundamentals III School of Science and Technology The University of New England Trimester 2 2015 Lecture 5: Java Fundamentals III - Operators Reading: Finish reading Chapter 2 of the 2nd

More information

Android NDK Native Development Kit

Android NDK Native Development Kit Contents 1. What you can do with NDK 2. When to use native code 3. Stable APIs to use / available libraries 4. Build native applications with NDK 5. NDK contents and structure 6. NDK cross-compiler suite

More information

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

More information

CS1020 Data Structures and Algorithms I Lecture Note #1. Introduction to Java

CS1020 Data Structures and Algorithms I Lecture Note #1. Introduction to Java CS1020 Data Structures and Algorithms I Lecture Note #1 Introduction to Java Objectives Java Basic Java features C Java Translate C programs in CS1010 into Java programs 2 References Chapter 1 Section

More information

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2015 The third

More information

CSC230 Getting Starting in C. Tyler Bletsch

CSC230 Getting Starting in C. Tyler Bletsch CSC230 Getting Starting in C Tyler Bletsch What is C? The language of UNIX Procedural language (no classes) Low-level access to memory Easy to map to machine language Not much run-time stuff needed Surprisingly

More information

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2014 Jill Seaman

More information

Using the Java Native Interface to Introduce Device Driver Basics

Using the Java Native Interface to Introduce Device Driver Basics Paper No. 102 Using the Java Native Interface to Introduce Device Driver Basics James K. Brown, Indiana University-Purdue University at Indianapolis ABSTRACT Teaching students to merge the real-world necessity

More information

JVM Tool Interface. Michal Pokorný

JVM Tool Interface. Michal Pokorný JVM Tool Interface Michal Pokorný JVM TI Inspect & control execution on JVM (profiling, debugging, monitoring, thread analysis, coverage, ) Higher-level interface: Java Platform Debugger Architecture JVM

More information

Java Cheatsheet. http://introcs.cs.princeton.edu/java/11cheatsheet/ Tim Coppieters Laure Philips Elisa Gonzalez Boix

Java Cheatsheet. http://introcs.cs.princeton.edu/java/11cheatsheet/ Tim Coppieters Laure Philips Elisa Gonzalez Boix Java Cheatsheet http://introcs.cs.princeton.edu/java/11cheatsheet/ Tim Coppieters Laure Philips Elisa Gonzalez Boix Hello World bestand genaamd HelloWorld.java naam klasse main methode public class HelloWorld

More information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection

More information

Memory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example

Memory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example Announcements Memory management Assignment 2 posted, due Friday Do two of the three problems Assignment 1 graded see grades on CMS Lecture 7 CS 113 Spring 2008 2 Safe user input If you use scanf(), include

More information

How To Write Portable Programs In C

How To Write Portable Programs In C Writing Portable Programs COS 217 1 Goals of Today s Class Writing portable programs in C Sources of heterogeneity Data types, evaluation order, byte order, char set, Reading period and final exam Important

More information

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. buford@alum.mit.edu Oct 2003 Presented to Gordon College CS 311

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. buford@alum.mit.edu Oct 2003 Presented to Gordon College CS 311 The Java Virtual Machine and Mobile Devices John Buford, Ph.D. buford@alum.mit.edu Oct 2003 Presented to Gordon College CS 311 Objectives Review virtual machine concept Introduce stack machine architecture

More information

RTI Connext DDS. Core Libraries Getting Started Guide Addendum for Android Systems Version 5.2.0

RTI Connext DDS. Core Libraries Getting Started Guide Addendum for Android Systems Version 5.2.0 RTI Connext DDS Core Libraries Getting Started Guide Addendum for Android Systems Version 5.2.0 1 2015 Real-Time Innovations, Inc. All rights reserved. Printed in U.S.A. First printing. June 2015. Trademarks

More information

www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 www.virtualians.pk

www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 Which of the following is a general purpose container? JFrame Dialog JPanel JApplet Which of the following package needs to be import while handling

More information

How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)

How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint) TN203 Porting a Program to Dynamic C Introduction Dynamic C has a number of improvements and differences compared to many other C compiler systems. This application note gives instructions and suggestions

More information

University of Twente. A simulation of the Java Virtual Machine using graph grammars

University of Twente. A simulation of the Java Virtual Machine using graph grammars University of Twente Department of Computer Science A simulation of the Java Virtual Machine using graph grammars Master of Science thesis M. R. Arends, November 2003 A simulation of the Java Virtual Machine

More information

An Empirical Security Study of the Native Code in the JDK

An Empirical Security Study of the Native Code in the JDK An Empirical Security Study of the Native Code in the JDK Gang Tan and Jason Croft Boston College gtan@cs.bc.edu, croftj@bc.edu Abstract It is well known that the use of native methods in Java defeats

More information

Java programming for C/C++ developers

Java programming for C/C++ developers Skill Level: Introductory Scott Stricker (sstricke@us.ibm.com) Developer IBM 28 May 2002 This tutorial uses working code examples to introduce the Java language to C and C++ programmers. Section 1. Getting

More information

Java Virtual Machine, JVM

Java Virtual Machine, JVM Java Virtual Machine, JVM a Teodor Rus rus@cs.uiowa.edu The University of Iowa, Department of Computer Science a These slides have been developed by Teodor Rus. They are copyrighted materials and may not

More information

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,

More information

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert Ubiquitous Computing Ubiquitous Computing The Sensor Network System Sun SPOT: The Sun Small Programmable Object Technology Technology-Based Wireless Sensor Networks a Java Platform for Developing Applications

More information

Using EDA Databases: Milkyway & OpenAccess

Using EDA Databases: Milkyway & OpenAccess Using EDA Databases: Milkyway & OpenAccess Enabling and Using Scripting Languages with Milkyway and OpenAccess Don Amundson Khosro Khakzadi 2006 LSI Logic Corporation 1 Outline History Choice Of Scripting

More information

COSC282 BIG DATA ANALYTICS FALL 2015 LECTURE 2 - SEP 9

COSC282 BIG DATA ANALYTICS FALL 2015 LECTURE 2 - SEP 9 COSC282 BIG DATA ANALYTICS FALL 2015 LECTURE 2 - SEP 9 1 HOW WAS YOUR WEEKEND? Image source: http://www.liverunsparkle.com/ its-a-long-weekend-up-in-here/ 1. Read and Post on Piazza 2. Installed JDK &

More information

Contents. Java - An Introduction. Java Milestones. Java and its Evolution

Contents. Java - An Introduction. Java Milestones. Java and its Evolution Contents Java and its Evolution Rajkumar Buyya Grid Computing and Distributed Systems Lab Dept. of Computer Science and Software Engineering The University of Melbourne http:// www.buyya.com Java Introduction

More information

To Java SE 8, and Beyond (Plan B)

To Java SE 8, and Beyond (Plan B) 11-12-13 To Java SE 8, and Beyond (Plan B) Francisco Morero Peyrona EMEA Java Community Leader 8 9...2012 2020? Priorities for the Java Platforms Grow Developer Base Grow Adoption

More information

Lecture 1 Introduction to Android

Lecture 1 Introduction to Android These slides are by Dr. Jaerock Kwon at. The original URL is http://kettering.jrkwon.com/sites/default/files/2011-2/ce-491/lecture/alecture-01.pdf so please use that instead of pointing to this local copy

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

Contents at a Glance

Contents at a Glance For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. Contents at a Glance Contents... v About

More information

Android Hands-On Labs

Android Hands-On Labs Android Hands-On Labs Introduction This document walks you through the 5 Android hands-on labs with i.mx53 Quick Start Board for today s session. The first part regards host preparation, which is not needed

More information

Comp151. Definitions & Declarations

Comp151. Definitions & Declarations Comp151 Definitions & Declarations Example: Definition /* reverse_printcpp */ #include #include using namespace std; int global_var = 23; // global variable definition void reverse_print(const

More information

The programming language C. sws1 1

The programming language C. sws1 1 The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan

More information

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1 The Java Series Java Essentials I What is Java? Basic Language Constructs Slide 1 What is Java? A general purpose Object Oriented programming language. Created by Sun Microsystems. It s a general purpose

More information

Object Oriented Software Design II

Object Oriented Software Design II Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February

More information

CSC 551: Web Programming. Fall 2001

CSC 551: Web Programming. Fall 2001 CSC 551: Web Programming Fall 2001 Java Overview! Design goals & features "platform independence, portable, secure, simple, object-oriented,! Language overview " program structure, public vs. private "instance

More information

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand: Introduction to Programming and Algorithms Module 2 CS 146 Sam Houston State University Dr. Tim McGuire Introduction To Computers And Java Chapter Objectives To understand: the meaning and placement of

More information

C++ Programming Language

C++ Programming Language C++ Programming Language Lecturer: Yuri Nefedov 7th and 8th semesters Lectures: 34 hours (7th semester); 32 hours (8th semester). Seminars: 34 hours (7th semester); 32 hours (8th semester). Course abstract

More information

Android Malware for Pen-testing. IOAsis San Fransicso 2014

Android Malware for Pen-testing. IOAsis San Fransicso 2014 Android Malware for Pen-testing IOAsis San Fransicso 2014 Dr. Who? Robert Erbes Senior Security Consultant (not a doctor) Target Audience The Malicious Defender i.e., Someone who believes that the best

More information

What is Java? Applications and Applets: Result of Sun s efforts to remedy bad software engineering practices

What is Java? Applications and Applets: Result of Sun s efforts to remedy bad software engineering practices What is Java? Result of Sun s efforts to remedy bad software engineering practices It is commonly thought of as a way to make Web pages cool. It has evolved into much more. It is fast becoming a computing

More information

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011 INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011 1 Goals of the Lecture Present an introduction to Objective-C 2.0 Coverage of the language will be INCOMPLETE

More information

02 B The Java Virtual Machine

02 B The Java Virtual Machine 02 B The Java Virtual Machine CS1102S: Data Structures and Algorithms Martin Henz January 22, 2010 Generated on Friday 22 nd January, 2010, 09:46 CS1102S: Data Structures and Algorithms 02 B The Java Virtual

More information

Tutorial: Getting Started

Tutorial: Getting Started 9 Tutorial: Getting Started INFRASTRUCTURE A MAKEFILE PLAIN HELLO WORLD APERIODIC HELLO WORLD PERIODIC HELLO WORLD WATCH THOSE REAL-TIME PRIORITIES THEY ARE SERIOUS SUMMARY Getting started with a new platform

More information

OpenCV on Android Platforms

OpenCV on Android Platforms OpenCV on Android Platforms Marco Moltisanti Image Processing Lab http://iplab.dmi.unict.it moltisanti@dmi.unict.it http://www.dmi.unict.it/~moltisanti Outline Intro System setup Write and build an Android

More information

Lecture 17: Mobile Computing Platforms: Android. Mythili Vutukuru CS 653 Spring 2014 March 24, Monday

Lecture 17: Mobile Computing Platforms: Android. Mythili Vutukuru CS 653 Spring 2014 March 24, Monday Lecture 17: Mobile Computing Platforms: Android Mythili Vutukuru CS 653 Spring 2014 March 24, Monday Mobile applications vs. traditional applications Traditional model of computing: an OS (Linux / Windows),

More information

Mobile application development J2ME U N I T I I

Mobile application development J2ME U N I T I I Mobile application development J2ME U N I T I I Overview J2Me Layered Architecture Small Computing Device requirements Run Time Environment Java Application Descriptor File Java Archive File MIDlet Programming

More information

CSC 551: Web Programming. Spring 2004

CSC 551: Web Programming. Spring 2004 CSC 551: Web Programming Spring 2004 Java Overview Design goals & features platform independence, portable, secure, simple, object-oriented, Programming models applications vs. applets vs. servlets intro

More information

A Short Introduction to Writing Java Code. Zoltán Majó

A Short Introduction to Writing Java Code. Zoltán Majó A Short Introduction to Writing Java Code Zoltán Majó Outline Simple Application: Hello World Compiling Programs Manually Using an IDE Useful Resources Outline Simple Application: Hello World Compiling

More information

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)

More information

picojava TM : A Hardware Implementation of the Java Virtual Machine

picojava TM : A Hardware Implementation of the Java Virtual Machine picojava TM : A Hardware Implementation of the Java Virtual Machine Marc Tremblay and Michael O Connor Sun Microelectronics Slide 1 The Java picojava Synergy Java s origins lie in improving the consumer

More information

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T) Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

More information

WRITING DATA TO A BINARY FILE

WRITING DATA TO A BINARY FILE WRITING DATA TO A BINARY FILE TEXT FILES VS. BINARY FILES Up to now, we have looked at how to write and read characters to and from a text file. Text files are files that contain sequences of characters.

More information

Cloud Computing. Up until now

Cloud Computing. Up until now Cloud Computing Lecture 11 Virtualization 2011-2012 Up until now Introduction. Definition of Cloud Computing Grid Computing Content Distribution Networks Map Reduce Cycle-Sharing 1 Process Virtual Machines

More information

5 Arrays and Pointers

5 Arrays and Pointers 5 Arrays and Pointers 5.1 One-dimensional arrays Arrays offer a convenient way to store and access blocks of data. Think of arrays as a sequential list that offers indexed access. For example, a list of

More information

Introduction to Object-Oriented Programming

Introduction to Object-Oriented Programming Introduction to Object-Oriented Programming Programs and Methods Christopher Simpkins chris.simpkins@gatech.edu CS 1331 (Georgia Tech) Programs and Methods 1 / 8 The Anatomy of a Java Program It is customary

More information

Java applets. SwIG Jing He

Java applets. SwIG Jing He Java applets SwIG Jing He Outline What is Java? Java Applications Java Applets Java Applets Securities Summary What is Java? Java was conceived by James Gosling at Sun Microsystems Inc. in 1991 Java is

More information

Restraining Execution Environments

Restraining Execution Environments Restraining Execution Environments Segurança em Sistemas Informáticos André Gonçalves Contents Overview Java Virtual Machine: Overview The Basic Parts Security Sandbox Mechanisms Sandbox Memory Native

More information

IBM SDK, Java Technology Edition Version 1. IBM JVM messages IBM

IBM SDK, Java Technology Edition Version 1. IBM JVM messages IBM IBM SDK, Java Technology Edition Version 1 IBM JVM messages IBM IBM SDK, Java Technology Edition Version 1 IBM JVM messages IBM Note Before you use this information and the product it supports, read the

More information

Install Java Development Kit (JDK) 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html

Install Java Development Kit (JDK) 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html CS 259: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center 319 8/19/2015 Install

More information

1 The Java Virtual Machine

1 The Java Virtual Machine 1 The Java Virtual Machine About the Spec Format This document describes the Java virtual machine and the instruction set. In this introduction, each component of the machine is briefly described. This

More information

Application-only Call Graph Construction

Application-only Call Graph Construction Application-only Call Graph Construction Karim Ali and Ondřej Lhoták David R. Cheriton School of Computer Science, University of Waterloo Abstract. Since call graphs are an essential starting point for

More information

An Incomplete C++ Primer. University of Wyoming MA 5310

An Incomplete C++ Primer. University of Wyoming MA 5310 An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages

More information

Number Representation

Number Representation Number Representation CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Topics to be Discussed How are numeric data

More information

A Java Virtual Machine Architecture for Very Small Devices

A Java Virtual Machine Architecture for Very Small Devices A Java Virtual Machine Architecture for Very Small Devices Nik Shaylor Sun Microsystems Research Laboratories 2600 Casey Avenue Mountain View, CA 94043 USA nik.shaylor@sun.com Douglas N. Simon Sun Microsystems

More information

Fundamentals of Java Programming

Fundamentals of Java Programming Fundamentals of Java Programming This document is exclusive property of Cisco Systems, Inc. Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors

More information

RTI Monitoring Library Getting Started Guide

RTI Monitoring Library Getting Started Guide RTI Monitoring Library Getting Started Guide Version 5.1.0 2011-2013 Real-Time Innovations, Inc. All rights reserved. Printed in U.S.A. First printing. December 2013. Trademarks Real-Time Innovations,

More information

Rootbeer: Seamlessly using GPUs from Java

Rootbeer: Seamlessly using GPUs from Java Rootbeer: Seamlessly using GPUs from Java Phil Pratt-Szeliga. Dr. Jim Fawcett. Dr. Roy Welch. Syracuse University. Rootbeer Overview and Motivation Rootbeer allows a developer to program a GPU in Java

More information

Installing Java. Table of contents

Installing Java. Table of contents Table of contents 1 Jargon...3 2 Introduction...4 3 How to install the JDK...4 3.1 Microsoft Windows 95... 4 3.1.1 Installing the JDK... 4 3.1.2 Setting the Path Variable...5 3.2 Microsoft Windows 98...

More information