Javatpoint Logo
Javatpoint Logo

Java Tools and Command-List

Programmers may write, debug, and optimize their code with the help of numerous tools and commands included with Java, a flexible and popular programming language. In this section, we will discuss the Java commands and tools, examining their features and the ways in which they aid in the development process.

Development Tools

1. Java Compiler - javac

Because it converts Java source code (.java files) into bytecode (.class files) that the Java Virtual Machine (JVM) can run, the javac command is essential for Java developers.

The Java source file you wish to compile in this case is called MyClass.java. Following compilation, the Java Virtual Machine (JVM) can run the matching MyClass.class file.

2. java - Interpreter for Java

Java applications are run with the Java command. It accepts as an argument the name of the class that contains the main method.

This command triggers the JVM to load the bytecode and execute the main method, initiating the program's execution.

Packaging and Deployment

3. jar - Java Archive Tool

Java applications and libraries are packaged into a single JAR (Java Archive) file using the jar tool. Distribution and deployment are made easier by it.

With the help of this command, the compiled class file MyClass.class is created as a JAR file called MyJar.jar. JAR files are easily exchanged and run across various platforms due to their portability.

Documentation

4. javadoc - The Java Documentation Generator

Javadoc uses Java source code comments to create HTML documentation. It is a vital tool for writing thorough and understandable code documentation.

javadoc MyClass.java

The tool helps you and others understand the purpose and usage of classes and methods by producing HTML documentation for the MyClass code.

Development Tools

5. javap - The Java Class File Disassembler

Java bytecode can be disassembled into human-readable code with javap. It is a helpful tool for looking at compiled class structures.

Disassembled bytecode instructions are included with the -c flag, providing information on how the Java code is converted into lower-level operations.

6. jdb - Java Debugger

The Java Debugger, or JDB tool, enables developers to step through code, check variables, and set breakpoints in order to debug Java applications.

It initiates interactive debugging for the given class (MyClass) in the Java Debugger.

Process Management

7. jps - Java Process Status Tool

JPS shows the Java process status on a computer. It is useful for finding the process IDs of active Java processes.

Finding Java processes and the associated process IDs is made easier with this.

8. jstack - Java Stack Trace Tool

Java thread stack traces of a specified process are printed by jstack. It is useful for troubleshooting thread-related problems.

Change <process_id> to the real process ID that you got from jps.

Performance and Monitoring

9. Jvisualvm - Java VisualVM

Java VisualVM is a graphical tool that offers comprehensive details about Java programs as they execute. It has tools for profiling, monitoring, and troubleshooting.

By executing the command, we can connect to and watch Java processes using the Java VisualVM application.

10. jmc - Java Mission Control

Java Mission Control is a performance monitoring, management, and diagnostics tool. It provides insights into the behavior and performance of Java applications:

Running this command opens Java Mission Control, allows us to connect to a running Java process for monitoring.

Integration and Native Code

11. javah -Java Header and Stub File Generator

javah makes it easier to integrate Java with native code by creating a C header and source files from a Java class.

javah is told to create files appropriate for use with JNI by using the -jni option.

Java 9 Features

12. jshell - Java Shell

Introduced in Java 9, jshell provides an interactive shell for evaluating Java expressions and statements. It is a great tool for experimenting with code snippets and trying out new features.

It opens the interactive shell, allows us to type and execute Java code directly.

13. jdeps - Java Class Dependency Analyzer

jdeps analyzes class files to determine their dependencies. It helps us to understand the structure of application and can be useful for identifying potential issues.

The command analyzes the dependencies of the specified class file.

14. javafxpackager - JavaFX Application Packager

For JavaFX applications, the javafxpackager tool helps package your application into a self-contained executable, including all dependencies:

The example creates a self-contained JAR file for a JavaFX application.

15. jlink - Java Linker

Starting from Java 9, jlink allows us to create a custom runtime image that includes only the modules and dependencies your application needs. It can result in smaller, more optimized runtime distributions:

Replace <path-to-modules>, <module-name>, and <output-directory> with your specific module information.

16. jmap - Java Memory Map

Prints shared object memory maps or heap memory details of a given process or core dump.

17. jhat - Java Heap Analysis Tool

Analyzes heap dumps generated by the JVM.

18. jstat - JVM Statistics Monitoring Tool

Monitors JVM statistics such as garbage collection, compilation, and more.

19. jrunscript - Command-Line Script Shell

Executes scripts written in languages supported by the Java Scripting API.

20. jimage - Java Image Tool

Displays, extracts, and lists modules and their content in a JImage file.

21. jconsole - Java Monitoring and Management Console

Graphical tool for monitoring and managing Java applications.

22. jdb - Java Debugger (Alternate Usage)

Launches the Java Debugger with the specified class.

23. jcmd - JVM Diagnostic Command

Sends diagnostic command requests to a running JVM.

24. jfr - Java Flight Recorder

Records and analyzes data from a running JVM.

25. jinfo - JVM Configuration Information

Prints configuration information for a given Java process.

26. jshell - Java Shell (Alternate Usage)

Launches the Java Shell with additional options.

27. jsadebugd - Java Serviceability Agent Debugger Daemon

Attaches to a Java process for debugging purposes.

28. jdeps - Java Class Dependency Analyzer (Alternate Usage)

Analyzes the dependencies of a JAR file.

29. jlink - Java Linker (Alternate Usage)

Creates a custom runtime image with additional options.

30. jmod - Java Module Archive Tool

Creates a modular JAR file from a set of modules.

31. jps - Java Process Status Tool (Alternate Usage)

Shows Java process status with additional information.

32. jrunscript - Command-Line Script Shell (Alternate Usage)

Executes a script with additional options.

33. jstatd - JVM Statistics Monitoring Daemon

Starts the JVM statistics monitoring daemon.

34. jweblauncher - Java Web Start Launcher

Launches Java applications distributed via Java Web Start.

35. jcmd - JVM Diagnostic Command (Alternate Usage)

Sends diagnostic command requests to a running JVM with additional options.

36. jconsole - Java Monitoring and Management Console (Alternate Usage)

Launches JConsole with additional options.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA