Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: How Does createObject Know Where To Get Object From?

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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.

    I followed instructions to get this far
    Continue reading the instructions.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Convert File Object to class<?> object
    By CEO in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: June 27th, 2012, 06:55 PM
  2. Creating object everytime object is called
    By aandcmedia in forum What's Wrong With My Code?
    Replies: 6
    Last Post: March 12th, 2012, 04:18 PM
  3. testing weather one object is greater than another object
    By u-will-neva-no in forum Object Oriented Programming
    Replies: 1
    Last Post: February 19th, 2012, 07:02 PM
  4. Reading from ResultSet to Object and from object Object Array
    By anmaston in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 7th, 2011, 06:11 AM
  5. Object as a Reference into Object's Class
    By Ace Coder in forum Object Oriented Programming
    Replies: 6
    Last Post: November 30th, 2010, 12:22 PM