Topic
  • 4 replies
  • Latest Post - ‏2014-04-18T16:48:45Z by dan_darnell
kennetheld
kennetheld
38 Posts

Pinned topic Java External Type

‏2014-04-18T01:34:34Z |

I hope someone can help me with this issue.  It is driving me nuts.  I have attached my complete project.  Basically I am trying to call an external Java Class ListContentDirectory from a Batch EGL program.  No matter how I try to pass the parms I run into an issue.  The current setup is defining the two input parms as individual strings and having it return an array (aryList) with the files in the directory.  I am currently getting the error below.

Description Resource Path Location Type
The method dim1string(Program, List) in the type Java2Egl is not applicable for the arguments (SQLRead, String[]) SQLRead.java /SQLRead/EGLGen/JavaSource/programs line 97 Java Problem
 

I am not sure how or where it is getting that I am passing an array in.  I am passing one back, but not in.  Basically I setup a Java External type in my EGL batch program, created a namespace and executed that external type to the class and get this error.  I am able to call the Class with another Java app no problem.  I have also tried passing an array.  Maybe the array coming back is an issue.  Not sure.  Any help would be GREATLY appreciated.  Thanks.

Attachments

  • markevans
    markevans
    2837 Posts

    Re: Java External Type

    ‏2014-04-18T12:38:45Z  

    Hi,

    Will take a look but can you

     

    a.)  Repost with your project using Export->General->Archive File.   This will provide all the settings as well as the egl source of the program you are calling.   An EGLAR is made to only contain  "compiled"  (.ir) files for IDE builds

    b.) what your real intention is here.  Are you trying to invoke a Java class from an EGL program or invoke an EGL program from a Java class?

    take care.

    Mark

  • kennetheld
    kennetheld
    38 Posts

    Re: Java External Type

    ‏2014-04-18T15:53:38Z  
    • markevans
    • ‏2014-04-18T12:38:45Z

    Hi,

    Will take a look but can you

     

    a.)  Repost with your project using Export->General->Archive File.   This will provide all the settings as well as the egl source of the program you are calling.   An EGLAR is made to only contain  "compiled"  (.ir) files for IDE builds

    b.) what your real intention is here.  Are you trying to invoke a Java class from an EGL program or invoke an EGL program from a Java class?

    take care.

    Mark

    Mark,

    Thanks so much for your willingness to help.  I have attached the file you requested.  This program is just trying a number of things we need to understand to move forward.  In the top of the main EGL program you will see where I am trying to call the External Type ListContentDirectory.  So to answer your question I am trying to call a Java class from within an EGL program and pass in parms and receive back an array.  I would prefer to pass in an array but have recently changed to passing in two parms instead since I thought that was causing issue.  Any thoughts and HELP would be GREATLY appreciated.  Thanks.

    Attachments

  • kennetheld
    kennetheld
    38 Posts

    Re: Java External Type

    ‏2014-04-18T16:16:07Z  
    • markevans
    • ‏2014-04-18T12:38:45Z

    Hi,

    Will take a look but can you

     

    a.)  Repost with your project using Export->General->Archive File.   This will provide all the settings as well as the egl source of the program you are calling.   An EGLAR is made to only contain  "compiled"  (.ir) files for IDE builds

    b.) what your real intention is here.  Are you trying to invoke a Java class from an EGL program or invoke an EGL program from a Java class?

    take care.

    Mark

    Mark,

    As I think more about this. if you have a sample, especially if it passes in parms and returns parms that would be very helpful as well.  It would give me other insight to accomplish this task.  I absolutely want to get an array back and would prefer sending an array but could deal with only sending multiple strings.  

    Again, thanks for all your help and consideration.

  • dan_darnell
    dan_darnell
    973 Posts

    Re: Java External Type

    ‏2014-04-18T16:48:45Z  

    Mark,

    As I think more about this. if you have a sample, especially if it passes in parms and returns parms that would be very helpful as well.  It would give me other insight to accomplish this task.  I absolutely want to get an array back and would prefer sending an array but could deal with only sending multiple strings.  

    Again, thanks for all your help and consideration.

    Kenneth,

    For EGL external types, use List in place of string arrays on the Java side. (Continue to use string array on EGL side.) Here is a working example using parts of your code:

    import java.io.*;
    import java.util.ArrayList;
    import java.util.List;
     
    public class ListContentDirectory {
     
      public List<String> directoryList(String pDirectory, String pCommand) {
      
          ArrayList<String> aryList = new ArrayList<String>(100);
    
          String strList = pCommand;
          
       if (strList.trim().equals("list")){
    
          //create file object
          File folder = new File(pDirectory);
          File[] listOfFiles = folder.listFiles();
    
           for(int i=0 ; i < listOfFiles.length ; i++){
                aryList.add(listOfFiles[i].getName());
                aryList.add(listOfFiles[i].getPath());
           }
       }
          return aryList;
      }
    }
    
    program SQLRead type BasicProgram {}
        
            
            function main()
                    
                    pDirectory string = "c:\\";
                    pCommand string = "list";
                    
                    myDirectory ListContentDirectory = new ListContentDirectory;
                    
                    aryList string[] = myDirectory.directoryList(pDirectory, pCommand);
                    
                    for(i int from 1 to aryList.getSize())
                            SysLib.writeStdout(aryList[i]);
                    end
                    
            end
                                     
    end
    
    // External Type to call Java class that processes directory commands
    ExternalType ListContentDirectory type JavaObject
            {packageName = "Directory", javaName = "ListContentDirectory"}
        function directoryList(pDirectory String in, pCommand String in) returns(string[]);
    end
    

    Hope this helps.


    Dan

    p.s. In the EGL documentation there is a really useful topic "Mapping EGL Primitives to Java" that will help you out when you get stuck on these data type translation issues.

     

     

    Updated on 2014-04-18T16:51:50Z at 2014-04-18T16:51:50Z by dan_darnell