<?xml version="1.0" encoding="windows-1252"?>
<node id="1006922" title="Java programming and Perl" created="2012-12-03 13:28:32" updated="2012-12-03 13:28:32">
<type id="115">
perlquestion</type>
<author id="956274">
heatblazer</author>
<data>
<field name="doctext">
&lt;h2&gt;Hello, all&lt;/h2&gt;
&lt;p&gt;I `ve heard rumors that Perl can be glued to other programming languages such as C++. I am interested how can this be done in Java, so I can use some tools from Perl I can`t normally use from Java, also, can I pack it into the jar file, so, let`s say, I can use a java program with Perl bindings on Android device? &lt;/p&gt;
&lt;p&gt;I`d really appreciate some small examples and explanations.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Edit&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Here is an example in Java with it`s defaults scripting engine(JS).&lt;/p&gt;
&lt;code&gt;

import javax.script.*;
import java.io.*;

class Jsc {
	public static void main(String[] args) {
		
		try {
			ScriptEngine engine = 
						new ScriptEngineManager().getEngineByName("javascript");
			for  ( String arg : args ) {
				FileReader fr = new FileReader(arg);
				engine.eval(fr);
			}
		} catch (IOException ioEX) {
			ioEX.printStackTrace();
		} catch (ScriptException scrEX) {
			scrEX.printStackTrace();
		}
	} //end of main
} //end of class
&lt;/code&gt;
&lt;p&gt;&lt;b&gt;Updated&lt;/b&gt; Passing a .js script file will result in executing it, also the js can interact with the program if programmed. Perl has Java modules from CPan, in Java cookbook by F.Darwin there is a topic: "Marrying Perl and Java" which gives a partial answer to my desire, but - it`s going from Perl, I need something as above code but with perls scripts so like I can program my java app with a small perl scirpt, let`s say perl script will search for files, java will read and execute them.(Just example, I won`t do exactly this). &lt;/p&gt;
&lt;p&gt;I wonder if it can be done with Perl? &lt;/p&gt;</field>
</data>
</node>
