Various Commands that are used in java are given below

A Java Compiler javac is a computer program or set of programs which translate java source code into java byte code.

Various Commands that are used in java are given below

A Java Compiler javac is a computer program or set of programs which translate java source code into java byte code.

Various Commands that are used in java are given below

Various Commands that are used in java are given below

 

1.javac

c:\ javac classname.java

A Java Compiler javac is a computer program or set of programs which translate java source code into java byte code.

Usage: javac <options> <source files>

where possible options include:

  • g Generate all debugging info
  • g:none Generate no debugging in
  • g:{lines,vars,source} Generate only some debugging info
  • nowarn Generate no warnings
  • verbose Output messages about what the compiler is doing
  • deprecation Output source locations where deprecated APIs are u

sed

  • classpath <path> Specify where to find user class files and annotation processors
  • cp <path> Specify where to find user class files and annotati

on processors

  • sourcepath <path> Specify where to find input source files
  • bootclasspath <path> Override location of bootstrap class files
  • extdirs <dirs> Override location of installed extensions
  • endorseddirs <dirs> Override location of endorsed standards path
  • proc:{none,only} Control whether annotation processing and/or compilation is done.
  • processor <class1>[,<class2>,<class3>...]Names of the annotation processors t

o run; bypasses default discovery process

  • processorpath <path> Specify where to find annotation processors
  • d <directory> Specify where to place generated class files
  • s <directory> Specify where to place generated source files
  • implicit:{none,class} Specify whether or not to generate class files for

implicitly referenced files

  • encoding <encoding> Specify character encoding used by source files
  • source <release> Provide source compatibility with specified release
  • target <release> Generate class files for specific VM version
  • version Version information
  • help Print a synopsis of standard options
  • Akey[=value] Options to pass to annotation processors
  • X Print a synopsis of nonstandard options
  • J<flag> Pass <flag> directly to the runtime system

2. java

c:\ java classname

Java interpreter translate the Java bytecode into the code that can be understood by the Operating System.

Usage: java [-options] class [args...]

(to execute a class)

or java [-options] -jar jarfile [args...]

(to execute a jar file)

where options include:

  • client to select the "client" VM
  • server to select the "server" VM
  • hotspot is a synonym for the "client" VM [deprecated]

The default VM is client.

  • cp <class search path of directories and zip/jar files>
  • classpath <class search path of directories and zip/jar files>

A ; separated list of directories, JAR archives, and ZIP archives to search for class files.

  • D<name>=<value>

set a system property

  • verbose[:class|gc|jni]

enable verbose output

  • version print product version and exit
  • version:<value>

require the specified version to run

  • showversion print product version and continue
  • jre-restrict-search | -jre-no-restrict-search

include/exclude user private JREs in the version search

  • ? -help print this help message
  • X print help on non-standard options
  • ea[:<packagename>...|:<classname>]
  • enableassertions[:<packagename>...|:<classname>]

enable assertions

  • da[:<packagename>...|:<classname>]
  • disableassertions[:<packagename>...|:<classname>]

disable assertions

  • esa | -enablesystemassertions

enable system assertions

  • dsa | -disablesystemassertions

disable system assertions

  • agentlib:<libname>[=<options>]

load native agent library <libname>, e.g. -agentlib:hprof

see also, -agentlib:jdwp=help and -agentlib:hprof=help 0

  • agentpath:<pathname>[=<options>]

load native agent library by full pathname

  • javaagent:<jarpath>[=<options>]

load Java programming language agent, see java.lang.instrument

  • splash:<imagepath>

show splash screen with specified image 1

3.javap

c:\ javap

This command provides the accessibility of the class members and other features given below . 2

Usage: javap <options> <classes>...

where options include:

  • c Disassemble the code
  • classpath <pathlist> Specify where to find user class files
  • extdirs <dirs> Override location of installed extensions
  • help Print this usage message
  • J<flag> Pass <flag> directly to the runtime system
  • l Print line number and local variable tables
  • public Show only public classes and members
  • protected Show protected/public classes and members
  • package Show package/protected/public classes

and members (default) 3

  • private Show all classes and members
  • s Print internal type signatures
  • bootclasspath <pathlist> Override location of class files loaded

by the bootstrap class loader

  • verbose Print stack size, number of locals and args for methods

If verifying, print reasons for failure

4. apt (command of bin directory) 4

c:\apt

This command gives the information about the class path .

Usage: apt <apt and javac options> <source files> 5

where apt options include:

  • classpath <path> Specify where to find user class files and annotati

on processor factories

  • cp <path> Specify where to find user class files and annotati

on processor factories 6

  • d <path> Specify where to place processor and javac generate

d class files

  • s <path> Specify where to place processor generated source files
  • source <release> Provide source compatibility with specified release
  • version Version information
  • help Print a synopsis of standard options; use javac -help for more options
  • X Print a synopsis of nonstandard options
  • J<flag> Pass <flag> directly to the runtime system
  • A[key[=value]] Options to pass to annotation processors
  • nocompile Do not compile source files to class files
  • print Print out textual representation of specified types
  • factorypath <path> Specify where to find annotation processor factories
  • factory <class> Name of AnnotationProcessorFactory to use; bypasses

default discovery process

See javac -help for information on javac options. 7

5 .javah

c:\javah

This command include the header files that contains the methods .we need to implement some native methods. You must be wondering about what's native methods. 8

On the other hand, native methods are the only way to use any system features not provided by the Java Virtual Machine.

Usage: javah [options] <classes>

where [options] include: 9

  • help Print this help message and exit
  • classpath <path> Path from which to load classes
  • bootclasspath <path> Path from which to load bootstrap classes
  • d <dir> Output directory
  • o <file> Output file (only one of -d or -o may be used)
  • jni Generate JNI-style header file (default)
  • version Print version information
  • verbose Enable verbose output
  • force Always write output files

<classes> are specified with their fully qualified names (forinstance, java.lang.Object).

6 . Javadoc

c:\javadoc classname.java 0

Javadoc is a program that is already included in JDK. We can use Javadoc to run over the source code to produce documentation of our classes in the HTML .

javadoc: error - No packages or classes specified.

usage: javadoc [options] [packagenames] [sourcefiles] [@files] 1

  • -overview <file> Read overview documentation from HTML file
  • public Show only public classes and members
  • protected Show protected/public classes and members (default)
  • package Show package/protected/public classes and members
  • private Show all classes and members
  • help Display command line options and exit
  • doclet <class> Generate output via alternate doclet
  • docletpath <path> Specify where to find doclet class files
  • sourcepath <pathlist> Specify where to find source files
  • classpath <pathlist> Specify where to find user class files
  • exclude <pkglist> Specify a list of packages to exclude
  • subpackages <subpkglist> Specify subpackages to recursively load
  • breakiterator Compute 1st sentence with BreakIterator
  • bootclasspath <pathlist> Override location of class files loaded by the bootstrap class loader
  • source <release> Provide source compatibility with specified release
  • extdirs <dirlist> Override location of installed extensions
  • verbose Output messages about what Javadoc is doing
  • locale <name> Locale to be used, e.g. en_US or en_US_WIN
  • encoding <name> Source file encoding name
  • quiet Do not display status messages
  • J<flag> Pass <flag> directly to the runtime system

Provided by Standard doclet:

  • d <directory> Destination directory for output files
  • use Create class and package usage pages
  • version Include @version paragraphs
  • author Include @author paragraphs
  • docfilessubdirs Recursively copy doc-file subdirectories
  • splitindex Split index into one file per letter
  • windowtitle <text> Browser window title for the documenation
  • doctitle <html-code> Include title for the overview page
  • header <html-code> Include header text for each page
  • footer <html-code> Include footer text for each page
  • top <html-code> Include top text for each page
  • bottom <html-code> Include bottom text for each page
  • link <url> Create links to javadoc output at <url>
  • linkoffline <url> <url2> Link to docs at <url> using package list at <url2>
  • excludedocfilessubdir <name1>:.. Exclude any doc-files subdirectories with given name.
  • group <name> <p1>:<p2>.. Group specified packages together in overview page
  • nocomment Supress description and tags, generate only de clarations.
  • nodeprecated Do not include @deprecated information
  • noqualifier <name1>:<name2>:... Exclude the list of qualifiers from the output.
  • nosince Do not include @since information
  • notimestamp Do not include hidden time stamp
  • nodeprecatedlist Do not generate deprecated list
  • notree Do not generate class hierarchy
  • noindex Do not generate index
  • nohelp Do not generate help link
  • nonavbar Do not generate navigation bar
  • serialwarn Generate warning about @serial tag
  • tag <name>:<locations>:<header> Specify single argument custom tags
  • taglet The fully qualified name of Taglet to register
  • tagletpath The path to Taglets
  • charset <charset> Charset for cross-platform viewing of generated documentation.
  • helpfile <file> Include file that help link links to
  • linksource Generate source in HTML
  • sourcetab <tab length> Specify the number of spaces each tab takes up in the source
  • keywords Include HTML meta tags with package, class and member info
  • stylesheetfile <path> File to change style of the generated documentation
  • docencoding <name> Output encoding name1 error

7 . jdb

c:\jdb -help 2

Java debugger helps in finding and the fixing of bugs in Java language programs. The Java debugger is denoted as jdb.

Usage: jdb <options> <class> <arguments>

where options include: 3

  • help print out this message and exit
  • sourcepath <directories separated by ";"> directories in which to look for source files
  • attach <address> attach to a running VM at the specified address using standard connector
  • listen <address> wait for a running VM to connect at the specified address using standard connector
  • listenany wait for a running VM to connect at any available address using standard connector
  • launch launch VM immediately instead of waiting for 'run' command
  • listconnectors list the connectors available in this VM 
  • connect <connector-name>:<name1>=<value1>,... connect to target VM using named connector with listed argument values
  • dbgtrace [flags] print info for debugging jdb
  • tclient run the application in the Hotspot(tm) Performance Engine (Client)
  • tserver run the application in the Hotspot(tm) Performance Engine (Server)

options forwarded to debuggee process:

  • v -verbose[:class|gc|jni] turn on verbose mode
  • D<name>=<value> set a system property
  • classpath <directories separated by ";"> list directories in which to look for classes
  • X<option> non-standard target VM option
  • <class> is the name of the class to begin debugging
  • <arguments> are the arguments passed to the main() method of <class>

For command help type 'help' at jdb prompt

8 .Applet viewer 4

C:\ appletviewer classname.html

Applet viewer is a command line program to run Java applets. It is included in the SDK. It helps you to test an applet before you run it in a browser.