How can I access a public static member of a Java class from ColdFusion?

How can I access a public static member of a Java class from ColdFusion?


Asked by: Leonardo833 | Posted: 21-01-2022






Answer 1

You run the createObject but don't call the "init" before running the static method. For example:

<cfset systemObject = createObject("java", "java.lang.System") />
<cfoutput>#systemObject.currentTimeMillis()#</cfoutput> 

In this case "currentTimeMillis()" is a static method of the System class.

Answered by: Roland131 | Posted: 22-02-2022



Answer 2

I would also mention that the class has to be in CF's classpath.

Answered by: Dainton490 | Posted: 22-02-2022



Similar questions

How to access Java Enum in ColdFusion?

How to pass an Enum like OAuthSignature.HTTPMethod as an argument to a Java method in ColdFusion? Thank you.


java - Call a ColdFusion function on another server?

I have a Java class I have to run, my current web host (shared) will not allow Java. I need to host it on another server. I was told I can't call Java from ColdFusion on a separate server, but what if I call a CF function on the 2nd server then have that function call the Java class, return the data to CF then that function go back to the original? Sorry if that sounds kludgy, but I can't think of any other solutions.


CSS Parser in ColdFusion or Java?

I'm building something that requires a simple HTML frontend for editing some properties in CSS. However, I need to get the value specified by a CSS file. The only parser I can find is CSS Parser Project , and it is in Java. It implements both Docume...


Best Way to Determine if *.doc File is RTF with Java or ColdFusion

So I have about 4,000 word docs that I'm attempting to extract the text from and insert into a db table. This works swimmingly until the processor encounters a document with the *.doc file extension but determines the file is actually an RTF. Now I know POI doesn't support RTFs which is fine, but I do need a way to determine if a *.doc file is actually an RTF so that I can choose to ignore the f...


java - Upgrading the JRE used by ColdFusion

I have a ColdFusion 8.1 application. It gets heavy use and I see jrun.exe getting very high memory usage in the task manager. This is a 32-bit windows 2003 server. When Jrun gets around a gig of memory usage ColdFusion will stop responding at some point. The logs are a little vague, but I start to see garbage collection and heap errors in the ColdFusion log. I assume that the JRE is running out of memory. I have th...


Java class cached in ColdFusion

When developing my own Java class to use within ColdFusion 8 I stumble upon a problem that ColdFusion doesn't recognize that the *.java or *.class was changed, at least i don't see the change I made appear on the page. Is it some kind of caching issue?


Register new mime-type in ColdFusion (Java)

My users are going to be uploading files with a .EXP extension. In ColdFusion on Windows 2003 I'm using getPageContext().getServletContext().getMimeType() to make sure that the file that they upload is of the correct mime-type, which will be text/plain. The issue I'm having is that no matter where I register the mime-type on the server, getPageContext().getServletContext().getMimeType() will return blank since it doesn't k...


java - Possible to create JSR 286 portlet using Coldfusion?

I was just thinking this morning, since ColdFusion is essentially built on JAVA, is it possible to create JSR 286 portlets using coldfusion? A search revealed that it might be possible, but I cannot find any material on this? Reason I ask is because I would love to be able to create Liferay compatible portlets with ColdFusion, as I am not a JAVA dev. Thoughts? Does anyone have any tutorials or refer...


java - Errors running Coldfusion 9 under Liferay 5.2 to serve portlets

So this all began in trying to get Coldfusion9 portlets to run under Liferay, just like examples that I've seen running JBOSS: http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSC00E3E9C-DC24-4488-930D-AEED19172CC5.html I followed those steps, but my application server would...


jakarta ee - Best Java EE server for ColdFusion

What is the best Java EE server to deploy coldfusion 9 on? I know there is Tomcat but i'm sure there are others.


java - Creating Javascript History like Object in Coldfusion

I want to create a History Object for my Website, It should be Similar to Javascript history object. I want to use this Object to Creating Previous/Next nevigational Links for my Website. The Problem with Javascript History Object is that it is based on the Window object, not a website specific. And Using this Object clicking on "Prvious" link can cause Leaving my website. What should be the best possible w...






Still can't find your answer? Check out these amazing Java communities for help...



Java Reddit Community | Java Help Reddit Community | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)



top