In this article we are going to see the commands and tools which are available after installing Java SDK.
Mainly we will focus on the basic of the command and we will see commands related to administrating java project.
I found this is helpful when you are using java for automation and managing java codes.
Goals
We need to learn these when we are doing management or maintenance java application or source. Like
- Running Selenium grid/ Standalone servers
- Running JMeter remotely
- Running JUnit packages
- Running Android unit tests
- Appending command in the build system for build or continuous integration in JAVA projects.
To install & configure java, please see this post
Before you read forward, you may need to have clear idea on followings :
What is JRE
- it is Java Run time Environment. JRE creates environment (JVM) to run ByteCode.
What is JVM
- Java Virtual Machine , which runs java code
What is JDK
Java development Kit, contains set of tools for java development. Here are basic components
- JRE
- Java Development Libraries
- Development Tools
- Runtime tools
- Management Tools
Bytecode
Bytecode is compiled java code ready to run. So, when I refer bytecode, i may mean following
- Class file (single compiled java class)
- JAR (java archive)
- WAT (java web archive)
- JWS (java web start) , not exactly a bytecode but can be used to run java app.
- JNLP(Java Network Launch Protocol), a xml configured file to run java app remotely.
JDK tools
Let’s see JDK tools in category
Java Launching Tools :
- java (Java application launcher)
- appletviewer (Java applet launcher)
- javaw (Java application launcher(same as java) without console window)
- javaws (Java Web Start launcher)
- extcheck (Checks version conflicts between a target JAR file and currently installed JAR file)
Java Development Tools :
- javac (Java programming language compiler commands)
- javadoc (Java code documentation commands)
- apt (java annotation Processor)
- jdb (Java Debugging Helper)
- javap (Disassembles compiled files(class) / print a representation of the byte codes)
- javah (C Header /Stub File Generator to associate native methods with code written in Java)
- jar (Compresses multiple files into one Java Archive (JAR) Runnable file)
- idlj (IDL file to java compiler/builder)
- orbd (To transparently locate and invoke persistent objects on servers in the CORBA environment)
Security Tools :
- keytool (key and certificate management utility)
- jarsigner (JAR Signing and Verification Tool)
- policytool (Manage policy files)- It has a GUI to work with
- kinit (obtains Kerberos v5 tickets(it’s a network authentication protocol))
- klist ( Gets all entries in credential cache and key tab)
- ktab ( Help the user to manage entries in the key table)
Scripting tool :
jrunscript (Command line script shell)
Converting tools :
- native2ascii (Convert text to Unicode Latin-1)
- HtmlConverter (Converts applets containing HTML page to a format which uses a Java Plug-in)
Deployment Tools :
- pack200 (Converts a JAR file into a pack200 compressed file)
- unpack200 (Converts a pack200 compressed file into a JAR file)
- javafxpackager (Packages JavaFX applications for deployment)
Monitoring Tools :
- jps (JVM Process Status Tool, shows the instrumented HotSpot JVMs on the target system)
- jstat (JVM Statistics Monitoring Tool)
- jstatd (RMI server application , monitors the creation and termination of instrumented HotSpot 4. JVMs and provides a interface to allow remote monitoring tools to attach to JVMs running on the local host)
Troubleshooting Tools :
- jhat (Java Heap Analysis Tool, parses java heap dump and launches web server to brows them)
- jinfo (Java configuration Info helper that prints configuration of a process /core file/remote debug server)
- jmap (prints shared object memory maps /heap memory details of a process or core file or a remote debug server)
- jstack (Java Stack Trace)
- jsadebugd (Serviceability Agent Debug Daemon)
Web Service Tools :
- wsgen (Generates JAX-WS portable artifacts.)
- wsimport (Generate JAX-WS portable artifacts.)
- xjc (Binding compiler for Java Architecture for XML Binding)
- schemagen (Java Architecture Schema generator for XML Binding.)
RMI & Server Tools :
- rmic (Generate stubs and skeletons for remote objects.)
- rmid (RMI activation system daemon.)
- rmiregistry (Remote object registry service)
- serialver (Return class serialVersionUID)
- java-rmi (Http to CGI request, forwarding to server commands)
- servertool (Administrating task like register, unregister, startup, and shutdown on a server)
- tnameserv (Provides access to the naming service.)
Tools with a GUI :
- jvisualvm (Manual page Java Visual VM )
- jconsole (Monitoring tool that provides information about the performance and resource consumption of applications running on the Java platform)
- Java Mission Control (oracle JDK only)
Java commands Syntax
commandName CommandOption ByteCodeName Parameters(Multiple are given in space)
like, for JAVA command, the syntax will be
java ( options ) class ( argument ... )
java ( options ) -jar file.jar ( argument ... )
And for javaw Command , the syntax will be
javaw ( options ) class ( argument ... )
javaw ( options ) -jar file.jar ( argument ... )
Note :
- Option : Command line options
- Class : Invoking class name
- file.jar : Invoking JAR file name
- argument : the arguments to pass while invoking.
Examples :
-
To know running java version :
java -version
-
To compile Java Class/program
javac _JavaclassName_.java
-
To run byte code with parameters
java _theclassName parameter1 parameter2 . . .
Thanks..:)