Java Development Kit - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Java Development Kit

Description:

Creates, adds files, updates, extracts and lists files to and from a jar. For example: ... Using a jar called program1.jar. c: java -cp program1.jar program1.Program1 ... – PowerPoint PPT presentation

Number of Views:661
Avg rating:3.0/5.0
Slides: 18
Provided by: bobst6
Category:
Tags: ajar | development | java | kit

less

Transcript and Presenter's Notes

Title: Java Development Kit


1
Java Development Kit
  • Dr. Robert Stumpf, Professor
  • Computer Information Systems

2
Java Development Kit
  • JDK (Java Development Kit) Components
  • Now also called the SDK (System Development Kit)
  • Use of the command prompt
  • Using it with jars and packages

3
JDK Components
  • Java files
  • Contain the source code
  • Must be named with the extension java
  • For example
  • Program1.java
  • Note class name equals file name

4
JDK Components
  • Class files
  • Contain the intermediate code
  • The intermediate code is interpreted by a virtual
    machine which converts it "on the fly" to
    appropriate binary code
  • Must be named with the extension class
  • For example
  • Program1.class

5
JDK Components
  • Jar files
  • Contain both the java and class files
  • Can also contain other files such as jpegs and
    gifs
  • Are understood by win zip
  • Contains a manifest file that is a directory of
    the contents enabling it to executed
  • For example
  • program1.jar

6
Use of the Command Prompt
  • javac.exe - The Java compilerproduces byte code
    from Java source code
  • Example of use javac Program1.java
  • Note again that the file name is the same as the
    class name

7
Use of the Command Prompt
  • java.exe - The Java interpreter runs the Java
    byte code
  • Example of use java Program1
  • Note that the file name is Program1.class
  • Note also that extension is left offwhen running
    it

8
Use of the Command Prompt
  • appletviewer.exe - The Java interpreter runs the
    Java byte code
  • Example of use appletviewer.program1.html
  • Requires a web page such as

9
Use of the Command Prompt
  • lthtmlgt
  • ltheadgt
  • lt/headgt
  • ltbodygt
  • ltapplet
  • codeprogram2.Program2.class
    archiveprogram2.jar width250 height300gt
  • lt/appletgt
  • lt/bodygt
  • lt/htmlgt

10
Using it with jars and packages
  • jar.exe - The Sun jar utility
  • Creates, adds files, updates, extracts and lists
    files to and from a jar
  • For example
  • jar cvf program1.jar Program1.class - Create
  • jar uvf program1.jar MyPanel.class - Update
  • jar xvf program1.jar MyPanel.class - Extract
  • jar tf program1.jar - List

11
Using it with jars and packages
  • Explanation
  • jar cvf program1.jar Program1.class - Create
  • jar uvf program1.jar MyPanel.class - Update
  • jar xvf program1.jar MyPanel.class - Extract
  • jar tf program1.jar - List
  • c create x extract f archive file
  • u update t list v verbose output

12
Use of Command Prompt
  • Using Command Prompt
  • To start (Windows 2000) use Start -gt Programs
    -gt MS-DOS Prompt (might also be under
    accessories)
  • To use first set path set pathc\j2sdk1.4.0\bin
    path
  • Assumes the SDK was installed in the root of C
    drive adjust as necessary
  • Many users put this set path in the autoexec.bat
    file or in their system registry

13
Use of Command Prompt
  • After setting path, run your program as follows
  • c\javac Program1.java
  • c\java Program1
  • If class is in a package, use
  • c\javac classpath mypackage.
    mypackage/Program1.java
  • c\java classpath mypackage.
    mypackage/Program1
  • Assumes Program1.java is in a sub-directory
    called mypackage
  • All class files will appear in the the
    subdirectory

14
Use of Command Prompt
  • Building a jar called program1.jar jar cvf
    program1.jar program1\.classNote jar name is
    same as package name and wild card used in jar
    command.
  • Using a jar called program1.jar
  • c\ java -cp program1.jar program1.Program1
  • Note package name is always used with class name

15
Use of Command Prompt
  • After setting path assuming using two jars called
    program1.jar and my.jar
  • c\java -cp program1.jarmyjar.jar
    mypackage/Program1
  • Assumes both program1.jar and myjar.jar are in
    the current directory
  • A semi colon is the separator character
  • -cp is an abbreviation for classpath that only
    works with the java command

16
Summary
  • The JDK or SDK is used world wide on many
    platforms
  • It is the back up system to use when workbenches
    such as Eclipse are not available
  • The JDK is something all employers expect you to
    know

17
Closing
  • Real Programmers should know
  • how to use the JDK
  • Thank You
  • Robert Stumpf
  • email rvstumpf_at_csupomona.edu
  • url www.csupomona.edu/rvstumpf
Write a Comment
User Comments (0)
About PowerShow.com