April 5, 2021
Confirming CF’s Java version via CFML code, in brief
Comments
(0)
April 5, 2021
Confirming CF’s Java version via CFML code, in brief
ColdFusion troubleshooter
Wizard 146 posts
Followers: 115 people
(0)
Have you ever wished you could confirm with 100% certainty what Java version is in use by the CF instance you are running? Or where the JVM’s location is (in case you are told to modify files related to it)? Maybe you don’t have access to the CF Admin, or aren’t sure you can trust you or a colleague are looking at the “right” CF Admin.
The good news is that ColdFusion offers simple ways/variables that can show you each of these, via CFML code. In this post, I share those. This post is a briefer version of a longer post I did today with more information on all this, covering several related points.
In CF2018 and above, to see the Java version and jvm directory location (in use by the CF server where the CFML code is running), use these variables:

server.system.properties.java.version
server.system.properties.java.home

You could of course use CFOUTPUT, CFDUMP, CFLOG or their cfscript equivalents. And if you wonder about still other JVM characteristics, you could use:

<cfdump var="#server.system.properties.java#">

or its cfscript equivalent, writedump, which will show ALL the variables that CF holds in that java struct.

In CF2016 and earlier, that system struct is not available in the Server scope, so instead you could use this code or a variation:

<cfscript>
system=createObject("java", "java.lang.System");
writeoutput(system.getproperty("java.version"));
writeoutput(system.getproperty("java.home"));
</cfscript>

For more on what all this can mean, how the JVM version you find may differ from your expectations, how to change the JVM version, as well as a Lucee variation of the first code above, and more, see the longer post on my own site, carehart.org.


For more blog posts from Charlie Arehart, see his posts here as well as his posts at carehart.org. And follow him on Twitter and other social media as carehart.

0 Comments
Add Comment