Download presentation
Presentation is loading. Please wait.
1
JDK, Jan Pettersen Nytun - HiA 1 The Java Programming Environment: The programmer write source code with a text editor. The programmer write source code with a text editor. One source file for each public class Classe1.java Classe2.java Classe1.class Classe2.class One class file for each class The source code is submitted to a compiler. The compiler translates the source code into Java bytecode. The source code is submitted to a compiler. The compiler translates the source code into Java bytecode. Bytecode is a low level language similar to machine language. compiling to bytecode
2
JDK, Jan Pettersen Nytun - HiA 2 The Java Programming Environment: executing the code Classe1.class Classe2.class A Java Virtual Machine (JVM) interprets (executes) the bytecode. A JVM is a program which simulates a machine A Java Virtual Machine (JVM) interprets (executes) the bytecode. A JVM is a program which simulates a machine A Java enabled browser contains a JVM. A Java “program” that can run inside a browser is called an applet. It is also possible to make stand-alone applications. The class loader, which is part of the JVM, will load classes as they are needed. Before the bytecode is interpreted it will be inspected by a bytecode verifier. The bytecode verifier will make sure that the bytecode is legal and that it don’t break Java’s security restrictions.
3
JDK, Jan Pettersen Nytun - HiA 3 The Java Programming Environment: compiling to native code native code compilers There are some native code compilers (compilers that generates code for a particular machine platform) available for Java, but just-in-time (JIT) compilers are more common. just-in-time (JIT) compiler A just-in-time (JIT) compiler will generate native code the first time a class is used, the code is cached for later use. hardware support Some hardware support for bytecode is also available.
4
JDK, Jan Pettersen Nytun - HiA 4 JDK JDK - Java Development Kit The Java Development Kit contains the software and tools that you need to compile, debug, and run applets and applications that you've written using the Java programming language. JDK is available free from SUN Microsystems, the creators of the Java programming language (http://java.sun.com/products/jdk/).
5
JDK, Jan Pettersen Nytun - HiA 5 the basic command-line tools Some of the basic command-line tools in the Java Development Kit (JDK) javacjavac -Is the Java compiler. Java source code (file with a.java extension) is compiled into Java bytecodes (class file, extension.class). javajava - Is the Java Interpreter, it executes Java class files. jdbjdb - Is a command-line debugger for Java classes. appletviewerappletviewer - Is the Java applet viewer, it allows you to run applets without a web browser. javahjavah - Is used to integrate C and Java. javapjavap - Disassembles class files. javadocjavadoc - Generates documentation from a Java source file.
6
JDK, Jan Pettersen Nytun - HiA 6 javap - javap - the Java Class Disassembler It is possible to do some reverse engineering from Java bytecode classes. With javap you can get a human-readable version of the specified Java bytecode classes. Usage: javap where options include: -c Print bytecode for each method (disassemble the code). -private Shows all classes, variables, and methods. Usage: javap where options include: -c Print bytecode for each method (disassemble the code). -private Shows all classes, variables, and methods.
7
JDK, Jan Pettersen Nytun - HiA 7 javap - javap - In the given example the file MenuApplet.class is disassembled C:\Java\myclasses>javap -private MenuApplet Compiled from MenuApplet.java public synchronized class MenuApplet extends java.applet.Applet implements java.awt.event.ActionListener /* ACC_SUPER bit set */ { public MenuApplet(); public void init(); public void actionPerformed(java.awt.event.ActionEvent); private void showPage(java.lang.String); }
8
JDK, Jan Pettersen Nytun - HiA 8 javadoc javadoc - Generates API documentation in HTML format from Java source code. The documentation describes the class, its inheritance hierarchy, and each nonprivate variable and method in the class. Comments in the source code that begin with /** and end with */ is also included. Each separate line of the comment must start with an *. Special tags placed in the source code are recognized. These doc tags enable you to autogenerate a complete, well- formatted API from your source code. The tags start with an "at" sign (@).
9
JDK, Jan Pettersen Nytun - HiA 9 javadoc javadoc - Example from a source file /* * MenuApplet.java * Copyright (c) 1998 HiA, All Rights Reserved. */ import java.applet.*; /** * This applet will display two buttons, each leading to a given URL. * @author Jan Pettersen Nytun * @version 1.1, 98/08/13 */ public class MenuApplet extends Applet implements ActionListener { /** * Initialize the applet. * @return void */ public void init() {...............
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.