<p dir="ltr">The main reason is to avoid distributing extra files with the application. Having just one exe or dll that can handle the "details" is much better.</p>
<p dir="ltr">I was also hoping to reuse the code in other similar projects that had different listeners. For example, a barcode reader javapos driver has different event signatures (different listener class), so it needs different java code. It would be nice if it could be encapsulated inside the pascal class instead of an external file.</p>
<p dir="ltr">Anyway the task is doable if someone can write the java code in a temporary file and invoke the compiler. If this is not possible I do not know if it can be done.</p>
<p dir="ltr">If you do not care about that then just use java glue code, it's simpler.<br>
</p>
<div class="gmail_quote">Στις 23 Απρ 2014 2:34 μ.μ., ο χρήστης "patspiper" <<a href="mailto:patspiper@gmail.com">patspiper@gmail.com</a>> έγραψε:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="quoted-text">On 23/04/14 13:20, Chriss Kalogeropoulos wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello everyone,<br>
<br>
a couple years ago i tried the same thing. The task was to implement a JavaPOS driver handler from Delphi/FPC code.<br>
The actual driver was implemented in C++ and it used a Java interface. My code was the glue between the application (Delphi/FPC) and the driver, it had to hook the events and call the appropriate methods for printing etc (it was a POS printer driver).<br>
<br>
I found that the only way to hook a native implemented listener to the java class was either to write a small piece of code in java to do the dispatching to my code OR use dynamic compilation to create the Java byte code. Basically i had to write the java code inside my dll (in a constact string) and pass this to the Java compiler to create the byte code in memory.<br>
This needed a lot of work and i dropped it since the actual java code was less than 30 lines and it was very generic, so it was not worth the effort.<br>
Check this<br>
<a href="http://www.javablogging.com/dynamic-in-memory-compilation/" target="_blank">http://www.javablogging.com/<u></u>dynamic-in-memory-compilation/</a><br>
<br>
This needs Java 6 (which was not an option in my case, i had to use older versions). It might help you.<br>
Also it needs to store the source files locally otherwise more dynamic class generation will be needed.<br>
The link above has the info you need.<br>
</blockquote>
<br></div>
If the java code is static, why would one need dynamic compilation?<br>
<br>
Stephano<div class="elided-text"><br>
______________________________<u></u>_________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.<u></u>org</a><br>
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/<u></u>cgi-bin/mailman/listinfo/fpc-<u></u>pascal</a><br>
</div></blockquote></div>