If you want to know which version of Java that you are using by code at runtime, you can do that by using the Java System property java.version. Let's see a code example,
package org.code2care.javaexamples;
/**
*
* How to know the Java Version
* using Java system property
* java.version
*
*
* @author code2care
*
*/
public class JavaVersionExample {
public static void main(String[] args) {
String javaVersion = getJavaVersion();
System.out.println(javaVersion);
}
public static String getJavaVersion() {
return System.getProperty("java.version");
}
}
Output: 15.02

More Posts related to Java,
- Read a file and Split using StringTokenizer in Java
- java: cannot infer type for local variable, cannot use var on variable without initializer
- IntelliJ Keyboard Shortcut to remove unused imports [Java]
- Split a String in Java with Examples
- StringTokenizer in Java with Examples
- Read a file using Java 8 Stream
- How to fix Java HTTP java.net.UnknownHostException
- [Fix] java: integer number too large compilation error
- Struts2 : java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext
- Add days/weeks/months/years to LocalDate in Java 8 and above examples
- XmlRpcException ConnectException connection refused error
- Your JBoss Application Server 7 is running However you have not yet added any users to be able to access the admin console
- How to create StackOverflow error in java
- Remove Trailing zeros BigDecimal Java
- How to verify if java is installed on the computer and get version detail
- Add two numbers using Java Generics
- [fix] Java NullPointerException ComparableTimSort countRunAndMakeAscending when sorting a List
- Create simple struts2 project using maven commands
- Parsing CSV file using Java code example (Comma Separated File)
- Get Client IP address from HTTP Response in Java
- 7 deadly java.lang.OutOfMemoryError in Java Programming
- Add newline character Java code example (\r \n \r\n)
- [Solution] Java Error Code 1603. Java Update did not complete.
- Create a Zip file using Java Code programmatically
- What is CA FE BA BE 00 00 00 3D in Java Class Bytecode
More Posts:
- Big Sur unsupported Mac [macOS] - MacOS
- SwissCovid App Launched in Switzerland - News
- This class should be public (android.support.v7.internal.widget.ActionBarView.HomeView) Lint Error - Android
- Add comma or semicolon at end of each line Notepad++ - NotepadPlusPlus
- Share Image and Text on Instagram from Android App using Share Dialog - Android
- How to backup a file in Linux/Unix - Linux
- How to Change Android Title Bar Color? - Android
- SharePoint Server 2016 error - Failed to connect to the configuration database - SharePoint