OpenJDK Installation Guide
This guide provides all the key information and getting-started instructions after a successful OpenJDK installation via DeploySage-CLI.
Basic Commands
Verify your installation and start compiling and running Java code.
# Check the Java runtime and compiler versions
java -version
javac -version
# Compile a Java source file
javac HelloWorld.java
# Run the compiled class file
java HelloWorld
# Create a JAR archive
jar cf my-app.jar *.class
Environment and Version Management
The installer sets up the JAVA_HOME environment variable and uses the system's alternatives to manage multiple Java versions.
To switch between multiple installed Java versions, use the alternatives command:
# Interactively select the default Java version
sudo alternatives --config java
# Interactively select the default Java compiler version
sudo alternatives --config javac
| Item | Value |
|---|---|
| Environment File | /etc/profile.d/java.sh |
| JAVA_HOME Path | e.g., /usr/lib/jvm/java-17-openjdk |
JVM and Development Tools
JVM Monitoring Tools
Build Tools
Your installation includes key tools for monitoring and development.
The installer also attempts to install common build tools like Maven and Gradle.
# List running Java processes
jps
# Display class loader statistics for a process
jstat -class <pid>
# Print a stack trace of all threads for a process
jstack <pid>
# Build a Maven project
mvn clean package
# Build a Gradle project
gradle build