Reputation: 12053
Is there such a thing as a system call that tells you if you are running on top of a "naked" JRE instead of a JDK-packed? (short of ClassNotFound exceptions).
Basic question indeed, but nothing bubbles up in Google/SO.
Upvotes: 1
Views: 263
Reputation: 1072
You can use the following trick in order to determine the existence of the JDK:
If the return value of javax.tools.ToolProvider.getSystemJavaCompiler()
is null
?
Then no compiler is available and your are running on top of a "naked" JRE.
Otherwise, the return value will be JavaCompiler
.
This will work on almost all of the scenarios, excepts if for some reason you include this JDK jar manually and not as part of the full JDK (on that case, it will not return null).
Upvotes: 2
Reputation: 35577
Obviously JRE
(Java Run-time Environment) is Java's run time environment.
JRE
Java Runtime Environment (JRE) contains JVM, libraries, and other supporting files. It does not contain any development tools such as compiler, debugger, etc. Actually, JVM runs the program, and it uses the class libraries, and other supporting files provided in JRE. If you want to run any java program, you need to have JRE installed in the system.
JDK
Java Developer Kit (JDK) contains tools needed to develop Java programs, along with the JRE to run the programs. The tools include compiler (javac.exe), Java application launcher (java.exe, jawaw.exe), Appletviewer, etc.
You need JDK only if you want to write programs, and to compile them. For running java programs, JRE is sufficient.
Upvotes: 1
Reputation: 5775
Everything runs on the JRE, JDK refers to the set of tools that allows java development like the javac compiler, or visualvm aplication to view information about running vms. There is no such a thing like running on the JDK
If you need to compile things on the fly you start another process calling the javac. Or you use the eclipse compiler for java which is a jar file that compiles java code bytecode.
Upvotes: 0