Java command-line tool cheat-sheet
·
140 words
·
1 minute read
java is a command-line tool to execute Java apps. It is Java application launcher.
Execute a Java .class file that contains a main method by using just the class name:
java classname
Execute a Java program and use additional third-party or user-defined classes:
java -classpath path/to/classes1:path/to/classes2:. classname
Execute a .jar program:
java -jar filename.jar
Execute a .jar program with debug waiting to connect on port 5005:
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 -jar filename.jar
Display JDK, JRE and HotSpot versions:
java -version
Display help:
java -help
More information: https://docs.oracle.com/en/java/javase/20/docs/specs/man/java.html .
I hope you enjoyed reading this post as much as I enjoyed writing it. If you know a person who can benefit from this information, send them a link of this post. If you want to get notified about new posts, follow me on YouTube , Twitter (x) , LinkedIn , and GitHub .