Forum Discussion

chicks's avatar
chicks
Regular Contributor
7 years ago

invoking java functions from testcomplete

I am trying to invoke testing functions written  in java  from testcomplete following 

Calling Functions From Java Classes 

https://support.smartbear.com/testcomplete/docs/testing-with/advanced/using-external-functions/calling-from-java-classes.html

 

I have defined  my java bridge and specified my jars, but code complete is not completing anything for JavaClasses

Under "Install Extensions"  Java Application Support and Java Classes Support is enabled.

 

It seems as if TestComplete is not seeing the java runtime ?

 

I have the Process Filter set to "use only selected processes"  I tried adding java to the process list,  and also selecting "use all processes"  but this did not seem to make any difference in showing Java clasess under code complete.

 

I am using version 12 .10 of TestComplete.

 

 

 

 

14 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    you have to add your classes as like below.

     

    <package name as like your import of that class>.<class name>

     

  • chicks's avatar
    chicks
    Regular Contributor

     

    That's got me to the next step. I was specifying java.dll rather than jvm.dll which was actually one folder down.

     

    Thanks Shankar and Alex.

  • cunderw's avatar
    cunderw
    Community Hero

    You say you have defined your jars, have you specified the classes you are wanting to call in the Java Classes section above the Class Paths?

  • chicks's avatar
    chicks
    Regular Contributor


    chickswrote:

    I am trying to invoke testing functions written  in java  from testcomplete following 

    Calling Functions From Java Classes 

    https://support.smartbear.com/testcomplete/docs/testing-with/advanced/using-external-functions/calling-from-java-classes.html

     

    I have defined  my java bridge and specified my jars, but code complete is not completing anything for JavaClasses

    Under "Install Extensions"  Java Application Support and Java Classes Support is enabled.

     

    It seems as if TestComplete is not seeing the java runtime ?

     

    I have the Process Filter set to "use only selected processes"  I tried adding java to the process list,  and also selecting "use all processes"  but this did not seem to make any difference in showing Java clasess under code complete.

     

    I am using version 12 .10 of TestComplete.

     

     

     

     


    My classes were uploaded. 

  • chicks's avatar
    chicks
    Regular Contributor

    I'm sorry Shankar,  I don't understand.

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      Hi,

       

      You must specify exact .jar file(s), but not just path to them. Check previous screenshot from Shankar where this is clearly illustrated.

       

      P.S. Well, the above text seems to be irrelevant as the help says that paths can be specified as well. The idea that I have at the moment: from the screenshot from your initial message, it looks like that you are referencing 64-bit Java runtime. What flavor of TestComplete you are using? 32-bit or 64-bit? This can be checked via the Help|About window. In case you are using 32-bit TestComplete, try to start 64-bit flavor from the <TestComplete>\x64\bin\ folder and check if it helps.
      Alternatively, you may try to reference 32-bit Java runtime and use 32-bit TestComplete.

      Not sure, but hope that this might help.
      If it does not, a screenshot that illustrates the observed behavior and the description of your expectations might help.

  • chicks's avatar
    chicks
    Regular Contributor

    I'm using 64  bit test complete 12.10.

    Changing to specify the 64  bit JRE does not seem to change the behavior.

    Changing to specify the exact jars does not seem to change the behavior.

     

    The desired behavior is that code complete gives me some dropdowns for the java classes.  However,  it remains empty.

    When I try: 

     

    function test_java_api() {

    bob = JavaClasses.excentus.tests.excentus.rl.rise.integration.api.RiseAPI;

    }

     

    I get: 

     

    'JavaClasses' is undefined Error location: Unit: "Shell_Member_Portal_suite\MemberPortal\Script\prototypes" Line: 4369 Column: 4.

    'JavaClasses' is undefined
    Error location:
    Unit: "Shell_Member_Portal_suite\MemberPortal\Script\prototypes"
    Line: 4369 Column: 4.
  • chicks's avatar
    chicks
    Regular Contributor

    do the java classes need to be under the test complete folder ?

    • shankar_r's avatar
      shankar_r
      Community Hero

      You have Java-bridge path as C:\Program Files(x86)\java\jre 1.8.0_9\bin\java.dll

       

      Change your Java Bridge folder to JDK like below.

       

  • chicks's avatar
    chicks
    Regular Contributor

    So i'm trying to "industrialize" this now, by which I mean move it off my laptop and have it run in test execute.  I downloaded the jar classes and jvm dll runtime onto the test execute machine.  However,  (I am guessing) that the java bridge property is not being updated properly on the test execute box.  

     

    Even when I update the java bridge in test complete and "save all" the files are not showing any updates on the test complete laptop.  I assumed it was part of the .pjs or .mds files but it does not seem to be.   

     

    Where is the java bridge property stored in the files ?  

  • chicks's avatar
    chicks
    Regular Contributor

    Thanks Shankar.  that's got it..... actually not copying the specified java bridge gives me the option of not maintaining the same version of the java runtime on each p latform.

     

    Regards,  Curt

    • shankar_r's avatar
      shankar_r
      Community Hero

      I guess, There is no way in TestComplete to copy your jvm path property to another TestComplete instance.

       

      But this operation has to part of your TestComplete/TestExecute installation.