Learn TOP-20 Java Commands - ByteScout
  • Home
  • /
  • Blog
  • /
  • Learn TOP-20 Java Commands

Learn TOP-20 Java Commands

Find the common java commands list along with some examples. Study a short description and use cases. Learn how to use the java command properly when programming.

1. javac

javac [ options ] [ sourcefiles ]

This javac command example and its options read an assortment of java class and interface definitions coded in the Java programming language. It then compiles them into bytecode and relevant class files. Additionally, the javac tool can also create annotations in an array of Java source files and classes.

2. Javap

javap [options] classes...

The javap command is responsible for disassembling of one or more class files. The out is dependent on the options used. When there is no option used, the javap command prints both the protected and public fields, and all the methods of the classes that are passed on to it.

3. rmic

rmic [ options ] package-qualified-class-name

You can use rmic compiler command to seamlessly create stub and skeleton class files using the Java Remote Method Protocol9 (JRMP) and automatically stub and tie all class files (IIOP protocol) for the remote protocol. The rmic compiler is the best tool for generating Object Management Group (OMG) Interface Definition Language (IDL)

4. klist

klist [ [-c] [-f] [-e] [-a [-n]] ] [-k [-t] [-K] ] [name] [-help]]

The klist command is used to display all entries in the local credentials cache and key table. The klist command enables the programmer to view entries in the local credentials cache and key table. The klist tool cannot be used to change the Kerberos database. It’s only used to verify the contents of the credentials cache or keytab.

5. Jarsigner

jarsigner [ options ] [jar-file alias} jarsigner -verify [ options ] jar-file [alias ...]

The jarsigner command plays two major purposes.

  • To sign JAR files with features that enable packaging of various digital data such as class files, sound, images, etc. in a single file for easier and faster distribution.
  • To verify the signatures and integrity of any signed Java Archive files.

6. Policytool

policytool [ -file ] [ filename ]

You can use policy tool command to read and write all plain text policy files regarding the user input through the utility GUI. The policy tool command calls an administrator’s GUI that helps the system administrator to manage the policy information of local policy files.

7. Keytool

keytool [commands]

Java keytool commands act as a key and certificate management utility. It helps end user to administer his or her own private/public key pairs and associated certificates that are used in self-authentication (where users are allowed to authenticate themselves to other users and services)

8. Jshell

jshell [options] [load-files]

You use jshell command when you want to interactively evaluate statements and declarations written in Java Programming Language in a read-eval-print loop (REPL)

9. jdeprscan

jdeprscan [ options ]{dir|jar|class}

You use the jdeprscan basic Java commands as a special static analysis tool that is used to scan a jar file (or an array of aggregation of class files) for the application of deprecated API elements. Jdeprscan tool is provided by JDK to scan files that are defined by Java SE. Other deprecated APIs from third-party libraries aren’t reported.

10. jpeds

jdeps [options] path ...

You can use jdeps command when launching the java class dependency analyzer. This java command syntax shows either the package-level or class level dependency of the Java class files.

11. jmod

jmod (create|extract|list|describe|hash) [options] jmod-file

You can use the jmod tool to develop JMOD files and also list the content of the existing JMOD flies. This Java programming command let you aggregate files other than .class files, resources, and metadata.

12. Jlink

jlink [options] --module-path modulepath --add-modules module [,module...]

You can use the jlink command to assemble and optimize an array of modules and their dependencies into a personalized run-time image. The command links the modules along with their transitive dependencies to establish a custom runtime image.

13. jar

jar [OPTION...] [ [--release VERSION] [-C dir] files] ...

The jar command is a very useful command. It creates an archive for classes and resources, also manipulates and restores individual classes or resources from respective classes. The jar command is more or less a general purpose archiving and compression tool. Its operation is based on the ZLIB or ZIP compression formats.

14. appletviewer

appletviewer [options] url...

You use of the appletviewer tool when launching the AppletViewer and operating applets outside the web browser. Although it is widely used and available and supported by JDK 9, the future of Applet API is uncertain and other options such as Java Web Start or self-contained applications are worth exploring.

15. java

Java command is technically used to launch any java application.

Examples:

For executing a class;

java [options] mainclass [args...]

For executing JAR file;

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

For executing the main class defined in a module;

java [options] [--module-path modulepath] --module module[/mainclass] [args...]

This command starts a java application by activating the Java Runtime Environment (JRE), enabling the specified class, and then calling the specified class’s main () method.

16. Javadoc

Javadoc [options] [packagenames] [sourcefiles] [@files]

You use the Javadoc command and its options to seamlessly generate HTML pages or API documentation from a given set of Java source files. This command parses the declarations and documentation comments in an array of java source files and produces the corresponding HTML pages that, by default settings, describe the public and protected classes, interfaces, fields, and nested classes.

17. javah

You can use this tool to automatically generate c header and source files from a java class

javah [options] fully-qualified-class-name ...

The c headers and source files generated are used to implement the native methods and to reference an object’s instance variable from the corresponding native source code.

18. Jstatd

jstatd [options ]

You use the jstatd command to observe the creation and termination of any instrumented Java Hotspot VM. This command requires the RMI server application and registry on the local host.

19. jconsole

jconsole [-interval=n] [-notile] [-plugin path] [-version] [connection ... ] [-J input argument

jconsole -help

You can use the jconsole command to launch a graphical console to monitor and manage all java applications. Java console commands are very recurring in a modern developers world.

20. schemagen

schemagen [ options ] java-files

You can use the scemagen command to generate a schema for every corresponding namespace that is referenced in your Java classes.

Bonus command!

wsimport

wsimport [ options ] wsdl_URI

This command pattern is used to generate Java API for the XML Web Services portable artifacts. All the artifacts can be packaged in a compressed form in a WAR file with the Web Service Description Language (WSDL) file or in schema files and the endpoint implementation ready for deployment.

 

About the Author

ByteScout Team

ByteScout Team of Writers

ByteScout has a team of professional writers specialized in different technical topics. We select the best writers to cover interesting and trending topics for our readers. We love developers and we hope our articles help you learn about programming and programmers.

 

 

 

prev
next