heatblazer has asked for the wisdom of the Perl Monks concerning the following question:
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?
I`d really appreciate some small examples and explanations.
Edit
Here is an example in Java with it`s defaults scripting engine(JS).
import javax.script.*; import java.io.*; class Jsc { public static void main(String[] args) { try { ScriptEngine engine = new ScriptEngineManager().getEngineByName("jav +ascript"); 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
Updated 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).
I wonder if it can be done with Perl?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Java programming and Perl
by tobyink (Canon) on Dec 03, 2012 at 18:36 UTC | |
by heatblazer (Scribe) on Dec 03, 2012 at 18:40 UTC | |
by tobyink (Canon) on Dec 03, 2012 at 18:45 UTC | |
by heatblazer (Scribe) on Dec 03, 2012 at 18:56 UTC | |
|
Re: Java programming and Perl
by ColonelPanic (Friar) on Dec 04, 2012 at 08:32 UTC | |
by heatblazer (Scribe) on Dec 04, 2012 at 10:54 UTC | |
by davido (Cardinal) on Dec 04, 2012 at 11:12 UTC | |
by heatblazer (Scribe) on Dec 04, 2012 at 14:35 UTC | |
by ColonelPanic (Friar) on Dec 04, 2012 at 11:11 UTC | |
by heatblazer (Scribe) on Dec 04, 2012 at 14:29 UTC | |
by tobyink (Canon) on Dec 04, 2012 at 14:38 UTC | |
| |
|
Re: Java programming and Perl
by Faern (Initiate) on Dec 04, 2012 at 18:48 UTC | |
by Anonymous Monk on Dec 10, 2012 at 01:06 UTC |