Wednesday, October 7, 2026
HomeJavaScriptCreating Java Lessons From JAR Information Utilizing "new java" In Adobe ColdFusion...

Creating Java Lessons From JAR Information Utilizing “new java” In Adobe ColdFusion 2025


When Adobe ColdFusion (ACF) 2025 got here out, one of many options that I used to be most enthusiastic about was the power to create remoted class loaders with the createObject() technique by explicitly supplying an array of JAR information. I might been doing this in Lucee CFML for years; so, when ACF lastly caught up, I used to be thrilled. In my pleasure, nonetheless, I missed the truth that this additionally works with the new java() operator as effectively. Admittedly, I have never used an excessive amount of of the extra intimate mechanics of ACF’s Java integration; so my oversight is not stunning. However, for anybody else who could have missed it, this is a fast demo.

Within the following CFML, I’ll load an occasion of the jSoup library in two methods:

  1. The old-school createObject() technique.
  2. The brand new-school new java() technique.

I haven’t got this JAR file loaded in my lib folder; so what we’re in search of right here is the power to load the Java class with out throwing a “class not discovered” exception.

<cfscript>

	// We will create an remoted class loader(s) utilizing this assortment of JARs.
	jarPaths = [
		expandPath( "/core/vendor/jsoup-1.23.2/jsoup-1.23.2.jar" ),
	];

	// Create new occasion of Java class utilizing conventional createObject().
	jSoup = createObject( "java", "org.jsoup.Jsoup", jarPaths );

	// Create new occasion of Java class utilizing "new java" development.
	jSoup2 = new java( "org.jsoup.Jsoup", jarPaths );

	writeDump([
		"With createObject": jSoup.getClass().getName(),
		"With new java": jSoup2.getClass().getName(),
	]);

</cfscript>

As you’ll be able to see, the new Java() technique (?operator?) take the goal class as the primary argument and the record of JAR information because the second argument. Identical to the createObject(); however with out the necessity to specify the sort of object. And, once we run this ColdFusion code, we get the next output:

  • With createObject: org.jsoup.Jsoup
  • With new java: org.jsoup.Jsoup

Works like a allure!

And simply to be clear, if I take away the jarPaths argument from both of the 2 invocations, I get the next error:

java.lang.ClassNotFoundException: org.jsoup.Jsoup
  at coldfusion.bootstrap.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:283)
  at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
  at coldfusion.runtime.java.JavaProxyFactory.getProxy(JavaProxyFactory.java:126)
  at coldfusion.runtime.ProxyFactory.getProxy(ProxyFactory.java:84)
  at coldfusion.runtime.CFPage._createObjectProxy(CFPage.java:10308)
  at coldfusion.runtime.CFPage._CreateObject(CFPage.java:10249)
  at coldfusion.runtime.CFPage._CreateObject(CFPage.java:10168)
  at coldfusion.runtime.CFPage._CreateObject(CFPage.java:10090)
  at coldfusion.runtime.CFPage.CreateObject(CFPage.java:9971)

The tighter Java integration is an actual hole in my understanding of current ColdFusion releases. It has been on my studying roadmap for some time; I simply have not had the necessity for it but. However I will positively use the new java operator beginning right this moment.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments