preloader
blog-post

Common Java commands for non Java Developers

Table of Contents

In this article we will see the usage of some common Java commands for non Java Developers.

Commands

Find Java Version

Command to get the Java version in your machine

java -version

Here is a example output from this command

openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1~18.04-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

Find Java Compiler Version

Command to get the Java compiler version

javac -version

Here is a example output from this command

javac 1.8.0_252

Compile Java Code

Command to compile a java program

javac my-program.java

Run Java Code

Command to run a java program

java my-program

Change default java version

Command to change the default java version if you have multiple java installed

sudo update-alternatives --config java

Find the java home

Command to find the java home

java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home'

Find Max Heap Size and Max RAM

Command to find the Max Heap Size and Max RAM in a machine

java -XX:+PrintFlagsFinal -XX:MaxRAM=1g -version | grep -Ei "maxheapsize|maxram"
Share this blog:
Comments

Related Articles