2 Replies Latest reply on Oct 19, 2012 5:18 PM by DrClap

    JPL - Java and Prolog

      Hey guys,

      I'm trying to check out the JPL at the moment and have one question:

      With JPL is it possible to access Prolog from Java and vice versa. For now, I'm just working with the direction: Java->Prolog.

      Is it possible, that I can reach from my prolog file (e.g. foo.pl) the specific instance of the object, that invoked the prolog file?

      I just only know, that I can create a new instance from a class with jpl_new and then I can access this instance of the object with the help of the other methods from JPL. But I want to access the "caller-instance", that invoked the prolog to be running.

      I hope you understand what I'm searching for. And sorry for my english, I'm from Germany and do my very best... ;)

      Thanks for help, guys!!!
        • 1. Re: JPL - Java and Prolog
          I think I have to access the JVM, where my Java application is running, or don't you think so??

          Is this possible??

          I need a solution for this problem: My Java program queries via JPL a .pl-file and executes this... Now I want, that the .pl-file may ask such "Java program, please give me the value of the current getName() back".... On the fly. While the java program is running.

          Is it possible, that, in this situation, Java and Prolog can "talk" to eachother?

          Thanks a lot!!!
          • 2. Re: JPL - Java and Prolog
            966541 wrote:
            But I want to access the "caller-instance", that invoked the prolog to be running.
            This sounds like a dubious design. Java objects don't have automatic access to the object which calls one of their methods, so why should you expect this to be a feature of JPL?

            When you write Java code which does require that the called method will have access to the calling object, the way you do that is for the calling object to pass "this" as one of the method parameters. Perhaps you should try this? I have no experience in JPL so I have no idea whether that is possible or not.