How Does createObject Know Where To Get Object From?
I am using Google's ZXing code for generating QR Codes from within a ColdFusion app. It's working fine, but I want to upgrade the libraries as we are looking for a higher-quality QR code.
I have zxing_core.jar and zxing_javase.jar files in a javaclasses directory.
My code has somevariable = createObject('java','com.google.zxing.BarCodeForma t')
HOW does java know where to get this object from?
That is, if I load zxing-1.6-core.jar and leave zxing_core.jar in place, how will Java or Cold Fusion know which one to take it from (if it exists in both) or will there be some kind of "conflict" that will make it not happen and cause errors?
RLS
--- Update ---
I guess what's truly baffling me is that I can also create objects from com.google.zxing.qrcode.qrcodewriter and com.google.zxing.clients.j2se and I don't see any files that have these names and I don't see where it could possibly be finding this information to load it.
Re: How Does createObject Know Where To Get Object From?
What class is the createObject() method in? What does the API doc for that class say?
Re: How Does createObject Know Where To Get Object From?
Norm, thanks for responding. I have no idea on how to answer your questions. I followed instructions to get this far, trying to understand it better now but don't know where to start.
Doing this:
<cfset BarcodeFormat = createObject('java','com.google.zxing.BarcodeForma t')>
<cfset writer = createObject('java','com.google.zxing.qrcode.QRCod eWriter')>
Lets me do this:
<cfset bitMatrix = writer.encode( origText, BarcodeFormat.QR_CODE, 200, 200 )>
and then later this:
<cfset converter = createObject('java','com.google.zxing.client.j2se. MatrixToImageWriter')>
<cfset buff = converter.toBufferedImage( bitMatrix ) />
<!--- convert it to a CF compatible image --->
<cfset img = ImageNew( buff ) />
<!--- display results --->
<CFIF ARGUMENTS.echoURL>
<b>Original Text = </b> <cfoutput>#origText#</cfoutput>
</CFIF>
<div>
<cfimage action="writeToBrowser" source="#img#" format="png">
</div>
RLS
Re: How Does createObject Know Where To Get Object From?
Sorry, I have no idea what you just posted or how it relates to java programming.
Quote:
I followed instructions to get this far
Continue reading the instructions.
Re: How Does createObject Know Where To Get Object From?
So, we are at a catch-22. What I am trying to figure out is how Java knows where to get the right file to load the right COM.whatever program.
I am guessing that when you load the libraries, those libraries have all the names in there and it just figures it out by checking some index.
SO, with that assumption, what happens when you load two libraries that have the SAME name of the COM.whatever object / class / whatever you're trying to load?
Sorry about the terminology - I don't know enough about Java to know how to ask the question correctly.
RLS
Re: How Does createObject Know Where To Get Object From?
Please post any java code you are having problems with.
What you posted was NOT java code. I don't know what language it is. It looks like XML.