SlideShare a Scribd company logo
Object Oriented
Programming – Java
By Daniel :
- javac
-java
-javah
-javadoc
-appletviewer
javac
 javac stands for Java Compiler
 The javac tool reads class and interface definitions, written in the Java
programming language, and compiles them into bytecode class files.
 There are two ways to pass source code file names to javac:
o For a small number of source files, simply list the file names on the
command line.
o For a large number of source files, list the file names in a file,
separated by blanks or line breaks.
javac (Cont..)
 Source code file names must have .java suffixes, class file names must have .class
suffixes, and both source and class files must have root names that identify the class.
For example, a class called MyClass would be written in a source file called
MyClass.java and compiled into a bytecode class file called MyClass.class.
 Inner class definitions produce additional class files. These class files have names
combining the inner and outer class names, such as MyClass$MyInnerClass.class.
 You should arrange source files in a directory tree that reflects their package tree. For
example, if you keep all your source files in /workspace, the source code for
com.mysoft.mypack.MyClass should be in
/workspace/com/mysoft/mypack/MyClass.java.
 By default, the compiler puts each class file in the same directory as its source file. You
can specify a separate destination directory with -d option
After using the javac command
as follow:
$ Javac car.java
We get car.class file ready to
be used by the launcher
(Car.class)
The work of the javac
javac
Sets the destination directory for class files. The
destination directory must already exist; javac will not
create the destination directory.
If a class is part of a package, javac puts the class file in a
subdirectory reflecting the package name, creating
directories as needed.
For example, if you specify -d /home/myclasses and the
class is called com.mypackage.MyClass, then the class
file is called
/home/myclasses/com/mypackage/MyClass.class.
java
java - Java application launcher
 The java tool launches a Java application. It does this by starting a Java
runtime environment, loading a specified class, and invoking that class's main
method.
 The method must be declared public and static , it must not return any value, and
it must accept a String array as a parameter. The method declaration must look
like the following: public static void main(String dims[]) By default, the first
non-option argument is the name of the class to be invoked.
 A fully-qualified class name should be used. If the -jar option is specified, the
first non-option argument is the name of a JAR archive containing class and
resource files for the application, with the startup class indicated by the Main-
Class manifest header.
 The Java runtime searches for the startup class, and other classes used, in three
sets of locations: the bootstrap class path, the installed extensions, and the user
class path. Non-option arguments after the class name or JAR file name are passed
to the main function.
What does the java launcher do?
java is called as ‘java launcher because It does this by starting a Java
runtime environment, loading a specified class, and invoking that class's
main method. This method must have the following signature: public static
void main(String[]). It has to be static and public. This means that it’ll have
the job of loading the .class file and making it ready for execution by the
Java Virtual Machine (JVM).
$ java runCar --runCar if the class with the main method:
javah
javah - C header and stub file generator
 The javah command generates C header and source files that
are needed to implement native methods. The generated
header and source files are used by C programs to reference
instance variables of an object from native source code. The
.h file contains a structure definition whose layout parallels
that of the corresponding class. The fields in the structure
correspond to instance variables in the class.
 The name of the header file and the structure declared
within it are derived from the name of the class. If the class
passed to javah is inside a package, the package name is
prepended to both the header file name and the structure
name. Underscores ( _ ) are used as name delimiters.
Javah (cont..)
 By default, javah creates a header file for each class listed on
the command line and puts the files in the current directory.
Use the -stubs option to create source files. Use the -o
option to concatenate the results for all listed classes into a
single file.
 The new native method interface, Java Native Interface
(JNI), does not require header information or stub files. The
javah command can still be used to generate native method
function prototypes needed for JNI-style native methods.
javah produces JNI-style output by default, and places the
result in the .h file.
 The javah_g version is a non-optimized version of javah
suitable for use with debuggers like jdb.
$ Javah runCar
This will create an header file for the class runCar that
can help in implementing the java code in C language. And
this command must be done on the class with the main
method, for our case now it is runCar.
After $ javah runCar we get:
Now we’ll try viewing what contained in the runCar.h file
$ cat runCar.h
This is how the runCar.h file looks like. Interesting, isn’t it?
javadoc
javadoc - Java API documentation generator
 The Javadoc tool parses the declarations and documentation comments
in a set of Java source files and produces a corresponding set of HTML
pages describing (by default) the public and protected classes, nested
classes (but not anonymous inner classes), interfaces, constructors,
methods, and fields.
 You can run the Javadoc tool on entire packages, individual source files,
or both. In the first case, you pass in as an argument to javadoc a series
of package names. In the second case, you pass in a series of source
(.java) file names. See EXAMPLES at the end of this document.
 NOTE - When you pass in package names to the Javadoc tool, it
currently processes all .java classes in the specified package directories,
even if the
 java files are code examples or other classes that are not actually
members of the specified packages. It does not parse each .java file for
a package declaration; we may add this parsing in a future release.
javadoc (cont..)
During a run, the Javadoc tool automatically adds cross-
reference links to package, class and member names that are
being documented as part of that run. Links appear in several
places:
o Declarations (return types, argument types, field types)
o "See Also" sections generated from @see tags
o In-line text generated from {@link} tags
o Exception names generated from @throws tags
o Specified by links to members in interfaces and Overrides links
to members in classes
o Summary tables listing packages, classes and members
o Package and class inheritance trees
This is an example of a javadoc
class. Note that all the method
and classes are public in
nature. The comments starts as
/** and ends with */. To
generate documentation for
this code, do:
$ Javadoc MyClass.java
The documentation to
generated is per java standards
of documentation.
MyClass.java
After :
$ Javadoc MyClass.java
You should see:
Now our java documentation MyClass.html is ready to use:
appletviewer
appletviewer - Java applet viewer
The appletviewer command connects to the documents or
resources designated by urls and displays each applet referenced
by that document in its own window.
Note:
if the documents referred to by urls do not reference any applets
with the OBJECT, EMBED, or APPLET tag, appletviewer does
nothing. For details on the HTML tags that appletviewer
supports, see
http://java.sun.com/j2se/1.5.0/docs/tooldocs/appletviewertags
.html.
Command:
$ appletviewer MyClass.html
Thank you!
By Daniel Ilunga

More Related Content

PPTX
Pi j4.1 packages
PPTX
chap 10 : Development (scjp/ocjp)
ODP
Ldapsession
ODP
Ldapsession 1217528612650451-9
PDF
WEB PROGRAMMING UNIT IV NOTES BY BHAVSINGH MALOTH
PDF
Java class loading tips and tricks - Java Colombo Meetup, January, 2014
PPTX
Access modifiers in java
PDF
EKON 12 Running OpenLDAP
Pi j4.1 packages
chap 10 : Development (scjp/ocjp)
Ldapsession
Ldapsession 1217528612650451-9
WEB PROGRAMMING UNIT IV NOTES BY BHAVSINGH MALOTH
Java class loading tips and tricks - Java Colombo Meetup, January, 2014
Access modifiers in java
EKON 12 Running OpenLDAP

What's hot (20)

PPTX
Consuming Libraries with CMake
DOCX
Unit2 java
PDF
Access modifiers
PPT
File class.48
PPTX
JLIFF, Creating a JSON Serialization of OASIS XLIFF
PDF
Ch23 xml processing_with_java
PPTX
Unit3 packages & interfaces
PPTX
Object oriented programming in php 5
PPT
Java non access modifiers
PDF
05 J2ME Wtk Command Line
PPT
Introduction To Ant
PDF
PPTX
Session 22 - Java IO, Serialization
PDF
Oracle DBA interview_questions
PPT
Packages(9 cm604.26)
PPTX
Session 23 - JDBC
PPTX
3.java database connectivity
PPTX
Hdfs connector api
PPT
Oops concepts in php
Consuming Libraries with CMake
Unit2 java
Access modifiers
File class.48
JLIFF, Creating a JSON Serialization of OASIS XLIFF
Ch23 xml processing_with_java
Unit3 packages & interfaces
Object oriented programming in php 5
Java non access modifiers
05 J2ME Wtk Command Line
Introduction To Ant
Session 22 - Java IO, Serialization
Oracle DBA interview_questions
Packages(9 cm604.26)
Session 23 - JDBC
3.java database connectivity
Hdfs connector api
Oops concepts in php
Ad

Viewers also liked (6)

PPTX
Features of java
PPTX
Features of java
PPT
Java features
PPTX
Steganography Project
PDF
Introduction to Java Programming
PPTX
Introduction to java
Features of java
Features of java
Java features
Steganography Project
Introduction to Java Programming
Introduction to java
Ad

Similar to Object Oriented Programming - Java (20)

PPTX
Java basics
PPTX
1 java programming- introduction
PDF
An Introduction to Java Compiler and Runtime
PPTX
Programming in Java
PDF
02 basic java programming and operators
PPT
Java Intro
PPTX
01. Introduction to programming with java
PPT
Java for Mainframers
PPTX
Java introduction
PPTX
2 22CA026_Advance Java Programming_Data types and Operators.pptx
PPTX
Introduction to java
PPTX
PDF
Java introduction
PPTX
oop unit1.pptx
PPTX
Introduction to Java Programming
PDF
Building Large Java Projects Faster: Multicore javac and Makefile integration
PPT
Java platform
PPTX
JAVA ALL 5 MODULE NOTES.pptx
PPTX
PDF
JAVA for Every one
Java basics
1 java programming- introduction
An Introduction to Java Compiler and Runtime
Programming in Java
02 basic java programming and operators
Java Intro
01. Introduction to programming with java
Java for Mainframers
Java introduction
2 22CA026_Advance Java Programming_Data types and Operators.pptx
Introduction to java
Java introduction
oop unit1.pptx
Introduction to Java Programming
Building Large Java Projects Faster: Multicore javac and Makefile integration
Java platform
JAVA ALL 5 MODULE NOTES.pptx
JAVA for Every one

More from Daniel Ilunga (6)

PDF
Leadership seminar presentation - Daniel Ilunga
PDF
GCC Compiler as a Performance Testing tool for C programs
PPTX
Six sigma
PPTX
Memory management
PPTX
Third parties are actively seeking out end-user information using Facebook
PPTX
DMA controller intel 8257
Leadership seminar presentation - Daniel Ilunga
GCC Compiler as a Performance Testing tool for C programs
Six sigma
Memory management
Third parties are actively seeking out end-user information using Facebook
DMA controller intel 8257

Recently uploaded (20)

PDF
VCE English Exam - Section C Student Revision Booklet
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Insiders guide to clinical Medicine.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
RMMM.pdf make it easy to upload and study
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
Cell Types and Its function , kingdom of life
PPTX
Cell Structure & Organelles in detailed.
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
VCE English Exam - Section C Student Revision Booklet
O7-L3 Supply Chain Operations - ICLT Program
Insiders guide to clinical Medicine.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Microbial disease of the cardiovascular and lymphatic systems
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Renaissance Architecture: A Journey from Faith to Humanism
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
GDM (1) (1).pptx small presentation for students
RMMM.pdf make it easy to upload and study
2.FourierTransform-ShortQuestionswithAnswers.pdf
01-Introduction-to-Information-Management.pdf
Classroom Observation Tools for Teachers
Cell Types and Its function , kingdom of life
Cell Structure & Organelles in detailed.
TR - Agricultural Crops Production NC III.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
human mycosis Human fungal infections are called human mycosis..pptx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape

Object Oriented Programming - Java

  • 1. Object Oriented Programming – Java By Daniel : - javac -java -javah -javadoc -appletviewer
  • 2. javac  javac stands for Java Compiler  The javac tool reads class and interface definitions, written in the Java programming language, and compiles them into bytecode class files.  There are two ways to pass source code file names to javac: o For a small number of source files, simply list the file names on the command line. o For a large number of source files, list the file names in a file, separated by blanks or line breaks.
  • 3. javac (Cont..)  Source code file names must have .java suffixes, class file names must have .class suffixes, and both source and class files must have root names that identify the class. For example, a class called MyClass would be written in a source file called MyClass.java and compiled into a bytecode class file called MyClass.class.  Inner class definitions produce additional class files. These class files have names combining the inner and outer class names, such as MyClass$MyInnerClass.class.  You should arrange source files in a directory tree that reflects their package tree. For example, if you keep all your source files in /workspace, the source code for com.mysoft.mypack.MyClass should be in /workspace/com/mysoft/mypack/MyClass.java.  By default, the compiler puts each class file in the same directory as its source file. You can specify a separate destination directory with -d option
  • 4. After using the javac command as follow: $ Javac car.java We get car.class file ready to be used by the launcher (Car.class) The work of the javac
  • 5. javac Sets the destination directory for class files. The destination directory must already exist; javac will not create the destination directory. If a class is part of a package, javac puts the class file in a subdirectory reflecting the package name, creating directories as needed. For example, if you specify -d /home/myclasses and the class is called com.mypackage.MyClass, then the class file is called /home/myclasses/com/mypackage/MyClass.class.
  • 6. java java - Java application launcher  The java tool launches a Java application. It does this by starting a Java runtime environment, loading a specified class, and invoking that class's main method.  The method must be declared public and static , it must not return any value, and it must accept a String array as a parameter. The method declaration must look like the following: public static void main(String dims[]) By default, the first non-option argument is the name of the class to be invoked.  A fully-qualified class name should be used. If the -jar option is specified, the first non-option argument is the name of a JAR archive containing class and resource files for the application, with the startup class indicated by the Main- Class manifest header.  The Java runtime searches for the startup class, and other classes used, in three sets of locations: the bootstrap class path, the installed extensions, and the user class path. Non-option arguments after the class name or JAR file name are passed to the main function.
  • 7. What does the java launcher do? java is called as ‘java launcher because It does this by starting a Java runtime environment, loading a specified class, and invoking that class's main method. This method must have the following signature: public static void main(String[]). It has to be static and public. This means that it’ll have the job of loading the .class file and making it ready for execution by the Java Virtual Machine (JVM). $ java runCar --runCar if the class with the main method:
  • 8. javah javah - C header and stub file generator  The javah command generates C header and source files that are needed to implement native methods. The generated header and source files are used by C programs to reference instance variables of an object from native source code. The .h file contains a structure definition whose layout parallels that of the corresponding class. The fields in the structure correspond to instance variables in the class.  The name of the header file and the structure declared within it are derived from the name of the class. If the class passed to javah is inside a package, the package name is prepended to both the header file name and the structure name. Underscores ( _ ) are used as name delimiters.
  • 9. Javah (cont..)  By default, javah creates a header file for each class listed on the command line and puts the files in the current directory. Use the -stubs option to create source files. Use the -o option to concatenate the results for all listed classes into a single file.  The new native method interface, Java Native Interface (JNI), does not require header information or stub files. The javah command can still be used to generate native method function prototypes needed for JNI-style native methods. javah produces JNI-style output by default, and places the result in the .h file.  The javah_g version is a non-optimized version of javah suitable for use with debuggers like jdb.
  • 10. $ Javah runCar This will create an header file for the class runCar that can help in implementing the java code in C language. And this command must be done on the class with the main method, for our case now it is runCar. After $ javah runCar we get:
  • 11. Now we’ll try viewing what contained in the runCar.h file $ cat runCar.h This is how the runCar.h file looks like. Interesting, isn’t it?
  • 12. javadoc javadoc - Java API documentation generator  The Javadoc tool parses the declarations and documentation comments in a set of Java source files and produces a corresponding set of HTML pages describing (by default) the public and protected classes, nested classes (but not anonymous inner classes), interfaces, constructors, methods, and fields.  You can run the Javadoc tool on entire packages, individual source files, or both. In the first case, you pass in as an argument to javadoc a series of package names. In the second case, you pass in a series of source (.java) file names. See EXAMPLES at the end of this document.  NOTE - When you pass in package names to the Javadoc tool, it currently processes all .java classes in the specified package directories, even if the  java files are code examples or other classes that are not actually members of the specified packages. It does not parse each .java file for a package declaration; we may add this parsing in a future release.
  • 13. javadoc (cont..) During a run, the Javadoc tool automatically adds cross- reference links to package, class and member names that are being documented as part of that run. Links appear in several places: o Declarations (return types, argument types, field types) o "See Also" sections generated from @see tags o In-line text generated from {@link} tags o Exception names generated from @throws tags o Specified by links to members in interfaces and Overrides links to members in classes o Summary tables listing packages, classes and members o Package and class inheritance trees
  • 14. This is an example of a javadoc class. Note that all the method and classes are public in nature. The comments starts as /** and ends with */. To generate documentation for this code, do: $ Javadoc MyClass.java The documentation to generated is per java standards of documentation. MyClass.java
  • 15. After : $ Javadoc MyClass.java You should see:
  • 16. Now our java documentation MyClass.html is ready to use:
  • 17. appletviewer appletviewer - Java applet viewer The appletviewer command connects to the documents or resources designated by urls and displays each applet referenced by that document in its own window. Note: if the documents referred to by urls do not reference any applets with the OBJECT, EMBED, or APPLET tag, appletviewer does nothing. For details on the HTML tags that appletviewer supports, see http://java.sun.com/j2se/1.5.0/docs/tooldocs/appletviewertags .html. Command: $ appletviewer MyClass.html