0% found this document useful (0 votes)
70 views

K1 Java

This document contains information about Java programming including: - A brief history of Java and how it was developed by Sun Microsystems starting in 1991. - Instructions on how to download and install the Java Development Kit (JDK) and check the installation. - An overview of common Java editors and the Java Development Toolkit (JDK) which includes tools like the Java compiler and interpreter. - Explanations of the Java Runtime Environment (JRE) and Java Virtual Machine (JVM) which allow Java bytecode to run on different platforms.

Uploaded by

arwana11
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views

K1 Java

This document contains information about Java programming including: - A brief history of Java and how it was developed by Sun Microsystems starting in 1991. - Instructions on how to download and install the Java Development Kit (JDK) and check the installation. - An overview of common Java editors and the Java Development Toolkit (JDK) which includes tools like the Java compiler and interpreter. - Explanations of the Java Runtime Environment (JRE) and Java Virtual Machine (JVM) which allow Java bytecode to run on different platforms.

Uploaded by

arwana11
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

4/14/2012

TIOBE Programming Community Index for 2009


indication of the popularity of programming languages.

Pemrograman Lanjutan 2
Muhammad Arief [email protected] Pebruari 2012

http://arief.ismy.web.id

http://arief.ismy.web.id

Java World

Bahan Kuliah
Pengenalan Java Sintaks Bahasa, Tipe Data, dan Operator, Kontrol Alur Eksekusi Program Konsep Pemrograman Berorientasi Objek Methods, Class dan Objek Pewarisan dan Polymorphism Abstract, Interface dan Penggunaannya Penanganan Eksepsi Pemrograman Multithreading Operasi I/O Java Collection Framework Java dan Database (JDBC) Membuat Graphical User Interface dengan SWING Applet

http://arief.ismy.web.id

http://arief.ismy.web.id

Buku
Liang, Y. Daniel (2009), Introduction to Java Programming, 7th ed., Person International Edition The Really Big Index: The Java Tutorial http://java.sun.com/docs/books/tutorial/ reallybigindex.html Harvey M. dan Paul J. Deitel (2004), Java ( ) How to Program, 6th edition, Pearson Education Zakhour, Sharon, Scott Hommel, Jacob Royal, Isaac Rabinovitch, Tom Risser, Mark Hoeber, The Java Tutorial : A Short Course on The Basics, 4th Ed., Prentice Hall

MINGGU Ke 1 Pemrograman Lanjutan 2


Pokok Bahasan: Pengenalan Java Tujuan Instruksional Khusus: g Java Installation, Java Tools, Java Program Referensi: The Really Big Index, The Java Tutorial : A Short Course on The Basics

http://arief.ismy.web.id

http://arief.ismy.web.id

4/14/2012

Java History
Dikembangkan oleh tim
Ketua: James Gosling Company: Sun Microsystem

Downloading Java and Installation


java.sun.com Download the latest version of JDK Download the documentation for JDK Install it onto your computer Visit Java Overview / Tutorial site

Agustus 1991, bernama Oak Januari 1995, berganti nama Java g Menjanjikan aplikasi berbasis Write Once, Run Anywhere (WORA) Dapat dijalankan di web browser dengan teknologi Applet

http://java.sun.com/docs/books/tutorial/infor mation/download.html

http://blogs.sun.com/thejavatutorials/ http://java.about.com/od/beginningjava/a/ beginjavatutor.htm http://java.about.com/od/beginningjava/a/ beginjavatutor.htm http://java.about.com/od/idesandeditors/tp/ begineditors.htm (top editors)

http://arief.ismy.web.id

http://arief.ismy.web.id

Check your setting installation


Check version: java version Can you compile? javac OR javac version Right Click MyComputer Properties Advanced Environment Variables
In User Variables add: Use a ab es
JAVA_HOME: C:\Program Files\Java\jdk1.6.0_07

Java Editor
Notepad, text editor Java Development Tools, aplikasi berbasiskan IDE (integrated development environment) untuk membuat program Java dengan cepat
JBuilder by Borland (www.borland.com) NetBeans Open Source by Sun (www.netbeans.org) p p y (www.eclipse.org) p g) Eclipse Open Source by IBM ( Code Warrior by Metrowerks (www.metrowerks.com) TextPad Editor (www.textpad.com) JCreator LE (www.jcreator.com) JEdit (www.jedit.org) JGrasp (www.jgrasp.org) BlueJ (www.bluej.org) DrJava (http://drjava.sourceforge.net)

In System Variables add:


PATH: ;C:\Program files\Java\jdk1.6.0_07\bin CLASSPATH: .;C:\Program files\Java\jdk1.6.0_07; C:\Program Files\Java\jdk1.6.0_07\bin; PathOfYourClasses
http://arief.ismy.web.id

http://arief.ismy.web.id

Java Development Toolkit (JDK)


Sekumpulan program terpisah untuk mengembangkan dan menguji program Java Program pada JDK yang sering digunakan
Java Compiler (javac)
Compiles programs written in the Java programming (.java) language into byte codes (.class).

Java Development Toolkit (JDK)


Debugger: jdb
Seperti interpreter, tetapi mampu men-debug aplikasi

Penampil applet: appletviewer


Menampilkan applet

Java Interpreter (java)


E Executes Java byte codes (.class). In other words, it runs t J b t d ( l ) I th d programs written in the Java programming language.

K Kompresi: jar i j
Menghasilkan kompresi (.jar) dari bytecode (.class) dan file pendukung lain (seperti gambar, suara, video)

Java Documentation Generator (javadoc)


Parses the declarations and documentation comments in a set of source files and produces a set of HTML pages describing the public and protected classes, interfaces, constructors, methods, and fields. Also produces a class hierarchy and an index of all members.

http://arief.ismy.web.id

http://arief.ismy.web.id

4/14/2012

Java Runtime Environment (JRE)


Software yang diperlukan untuk menjalankan aplikasi berplatform Java Java Virtual Machine (JVM): sekumpulan program untuk mengeksekusi java bytecode agar jalan pada platformnya Java Bytecode: Sekumpulan instruksi yang dieksekusi oleh JVM. Panjangnya sebesar 1 byte per instruksi

Java Platform

http://arief.ismy.web.id

http://arief.ismy.web.id

Java Virtual Machine (JVM)


Java source code compiled to bytecodes. An architecture-neutral machine code. Bytecodes is the machine language of the JVM Executed by running the JVM The Java virtual machine is an abstract computing machine that has an instruction set and manipulates memory at run time. t d i l t t ti JVM -implemented once for each computer. Hence Java software is: Write Once, Run Everywhere

Portability
Java executables run on all computer systems (Windows, Macintosh, Unix, Linux, etc.) At the expense of performance? f f ? 10% - 15% slower than C

http://arief.ismy.web.id

http://arief.ismy.web.id

Your First Java


Create a Java Class Source Code
Use any editor: notepad, netbeans, eclipse, PHP editor, JCreator, TextPad etc

Creating, Compiling, Executing


Create/Modify Source Code Source code (developed by the programmer) Hasil: Welcome.java public class Welcome { Save on the disk public static void main(String [] args) { Source Code System.out.println(Welcome to Java!); } } Compile Source Code e.g., javac Welcome.java Hasil: Welcome.class Bytecode (generated by the compiler for JVM to read If compilation errors and interpret, not for you to understand)
Stored in the disk

Save as ClassName.java Compile the source code**


Command: javac ClassName.java j j

Compiled class: ClassName.class Run the program**


Command: java ClassName

Method Welcome() 0 aload_0 Method void main(java.lang.String[]) 0 getstatic #2 3 ldc #3 <String Welcome to Java!> 5 invokevirtual #4 8 return

Bytecode

Run Bytecode e.g., java Welcome


If runtime errors or Incorrect result

** : from command prompt


http://arief.ismy.web.id

Result

http://arief.ismy.web.id

4/14/2012

Compile Time and Run Time

http://arief.ismy.web.id

http://arief.ismy.web.id

Your First Java


// This application program prints Hello World!
Class name

Explanation
Comments

public class HelloWorld { public static void main(String[] args) { Command Line Arguments System.out.println("Welcome to Java !"); } Class heading heading, String } Main method signature

Filenam: HelloWorld.java

The keyword class begins the class definition for a class named HelloWorld. the code for each class appears between the opening and closing curly braces. every application must contain a main method S stem o t println(Welcome to Ja a!"); System.out.println(Welcome Java!"); uses the System class from the core library to print the Welcome to Java!!" message to standard output. HelloWorld is different than Helloworld (case sensitive)
http://arief.ismy.web.id

http://arief.ismy.web.id

Your Second Java


class StringDemo { public static void main ( String[] args ) { for (int j=0; j < args.length; j++ ) System.out.println( "Parameter " + j + ": " + args[j] ); } }

Your Third Java


// This application program prints arguments public class HelloArgs{ public static void main(String testAja[]) { System.out.println(testAja[0]); System.out.println(testAja[1]); } }

http://arief.ismy.web.id

http://arief.ismy.web.id

4/14/2012

Your Fourth Java


class InputDemo { public static void main ( String[] args ) { int sum = 0; for (int j=0; j < args.length; j++ ) sum += Integer.parseInt(args[j]); System.out.println( "Sum: " + sum ); } }
http://arief.ismy.web.id

You might also like