I got a Java application, I want to provide user ability to compile Java source code (Using JavaCompiler interface)
If the user run the application on a JRE, my application should tell user that the no JavaCompiler instance aviable.
so how to detect JDK or JRE in java programe?
You might have either JRE(Java Runtime Environment) which is required to run java applications on the computer or JDK as shown below. 1. Open command prompt and enter “java –version”. If installed version number is displayed.
What is the latest Java version? As of September 2022, Java 19 is the latest released Java version.
The JRE is an abbreviation for Java Runtime Environment. The JVM is an abbreviation for Java Virtual Machine. The JDK (Java Development Kit) is a software development kit that develops applications in Java. Along with JRE, the JDK also consists of various development tools (Java Debugger, JavaDoc, compilers, etc.)
You can request an implementation of JavaCompiler
from ToolProvider
. If it returns null
, there is no implementation of JavaCompiler
available:
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
if (c == null) {
// JRE
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With