Great, thanks, I haven't tested yet but that answer should be enough to get me up and running with the scenario where PL is using Java in an auxiliary fashion.
Now pretend I have a PL database that listens on say port 4040, could it be possible to use the current Java interop code to pass data to that database for storage? Data that might be coming as a HTTP request to a servlet for instance. It doesn't have to be fancy, simply having a Java vector/array (or whatever the simplest sequential Java construct is called) appear as a list in PL would be enough to get me started. On Thu, May 27, 2010 at 10:07 AM, Alexander Burger <[email protected]> wr= ote: > Hi Henrik, > >> Hi Alex, I just took a look at the old java gui download. >> ... >> communicating with a running JVM from PL. > > The starting point is the class "java/Reflector.java", together with the > start-up shell script "java/vm". > > 'Reflector' is a kind of "Java functionality server". It mediates - as > you observed - between the Java and PicoLisp worlds. > > Also included is a demo Java library "java/Util.java", containing some > Java functions be callable from PicoLisp. You can start it as > > =A0 $ java/vm java/util.jar & > > Now the Java functionality server is running in the background. The > startup script created a named pipe "fifo/java" where the server is > listening at. > > Now any PicoLisp program can load "lib/java.l", and requests the > execution of Java functions on that server: > > =A0 : (load "lib/java.l") > =A0 -> java > > =A0 : (java 'Util 'md5 "This is a string") > =A0 -> 87704939138141002822102625569266896500 > =A0 : (hex @) > =A0 -> "41FB5B5AE4D57C5EE528ADB00E5E8E74" > > =A0 : *Pid > =A0 -> 15561 > > If you look now into the "fifo/" directory > > =A0 prw-r--r-- 1 abu abu 0 May 27 09:15 java| > =A0 prw-r--r-- 1 abu abu 0 May 27 09:15 java15561| > > you see that the PicoLisp process created another fifo with its PID in > the name, to receive the answers from the server. > > The types of requests the Reflector understands is rather limited. It > could be > > =A0 - static methods (when the second argument is a symbol or string > =A0 =A0 (like 'md5' above), or > > =A0 - methods invoked on a 'new' object which is created on the fly (when > =A0 =A0 the second argument is NIL or a list) > > In the second case, NIL causes the creation of a Java object of the > given class (in the first argument). I don't remember exactly what a > list of classes means (calling getConstructor() with a list of classes), > as I never needed that. If you should need it, we must investigate a > little more ... > > >> fork routine) and then having the Java end use the code in inOut.java >> to print to and read from this port? > > As you see from the above examples, the PicoLisp side doesn't need to > worry about the communication details (just call 'java'), and the Java > side also doesn't need that, as the Java reflection api takes care of > that so that you can concentrate on the Java side just on writing proper > functions. > > >> Btw there are two java folders, java and java2, what is the difference? > > 'java' should be sufficient here. 'java2' contains only the newer > version of the GUI (Swing instead of AWT), and the Z3dField class for > the 3D graphics (used in the flight simulator). > > Cheers, > - Alex > -- > UNSUBSCRIBE: mailto:[email protected]?subject=3dunsubscribe > -- UNSUBSCRIBE: mailto:[email protected]?subject=unsubscribe
