Re: Pass an array from Python to Java for use in the main method
Jeff Emanuel <[email protected]>
| Newsgroups | gmane.comp.lang.jython.user |
|---|---|
| Message-ID | <[email protected]> |
The java main method is defined to accept a String[] only. You can't call it with different arguments.
Define a different method that takes the arguments you want and call that. This tells you how:
http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html
On 1/11/2015 7:32 PM, haider riaz wrote:
> Hello
>
> I am trying to develop an imaging denoising software written in Jython with C components. Using JNA (Java Native Access), I can call C programs from java. Specifically, I can send an array to C , manipulate the array there, and then return it to my Java main method. The next step that I want to accomplish is to pass an array (plus an int specifying the size of the array) from my Python module to a Java class's main method (and from there it will be passed on to a C program), and then return the manipulated array back to the Python module. I am not sure how to proceed with this. Can someone put me on the right track? Thank you. Below is my incomplete Java Code for implementation of what I described above:
>
>
> public class JythonArrayTransit {
>
>
> publicinterfaceCTest extendsLibrary {
> public float JythonArray(Pointer p, int numVals);
> public void cleanup(Pointer s);
> }
>
>
> static public void main(String argv[]) {
> System.setProperty("jna.library.path", "/Users/haiderriaz/Desktop/JNA-C/ArrayFromJython");
> CTest ctest= (CTest) Native.loadLibrary("Farray", CTest.class);
> Pointer wand = new Memory(sizeArr * Native.getNativeSize(Float.TYPE));
>
> // get wand to point to my array from Jython .
> ctest.JythonArray(wand, sizeArr);
> for (int dloop=0; dloop<sizeArr; dloop++) {
> double print = wand.getDouble(dloop * Native.getNativeSize(Double.TYPE));
> System.out.println("\tvalue: " + print);
> }
>
>
> ctest.cleanup(wand);
>
>
> }
>
> }
>
>
> Thank you again
>
> Haider
>
>
> ------------------------------------------------------------------------------
> New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
> GigeNET is offering a free month of service with a new server in Ashburn.
> Choose from 2 high performing configs, both with 100TB of bandwidth.
> Higher redundancy.Lower latency.Increased capacity.Completely compliant.
> vanity: www.gigenet.com
>
>
> _______________________________________________
> Jython-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jython-users
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
vanity: www.gigenet.com
_______________________________________________
Jython-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-users