Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^3: Inline::Java Question

by wpflum (Initiate)
on Feb 03, 2012 at 20:19 UTC ( #951708=note: print w/replies, xml ) Need Help??

in reply to Re^2: Inline::Java Question
in thread Inline::Java Question

I was able to drop the external class I made to interface to the awt class in java but I still get an error when it tries to send the image object to the java class to load it. I can actually print the object $image and I get InLine::Java::Object=HASH(0x94da3a8) Here is the code:
#!/usr/bin/perl use strict; use warnings; use Inline (Java => 'STUDY', CLASSPATH => '/usr/share/java/RXTXcomm.jar:/home/billp/Deskt +op/perl/SigPlus2_57.jar:/home/billp/Desktop/perl/rt.jar', STUDY => ['com.topaz.sigplus.SigPlus','java.awt.Image'], AUTOSTUDY =>1); use Inline Java => <<EOJ; import java.awt.*; public class ADMLibrary{ public Image GetJavaImageObject(String Filename) { return Toolkit.getDefaultToolkit().getImage(Filename); } } EOJ my $filename = "/home/billp/Desktop/perl/Screen2.jpg"; my $adm = new ADMLibrary(); my $image = $adm->GetJavaImageObject($filename); my $sigobj = new com::topaz::sigplus::SigPlus(); $sigobj->lcdWriteImage(0, 2, 3, 46, 233, 24, $image); 1;
Any Suggestions??

Replies are listed 'Best First'.
Re^4: Inline::Java Question
by tobyink (Abbot) on Feb 03, 2012 at 22:30 UTC

    My general advice when using Inline is to keep data passed between Perl and the other language as simple as possible. Passing a Perl object to a Java object as a method parameter is doable, but seems advisable. I tried to make sure I was only passing strings through to Java.

    Clearly some Java classes expect more complex data structures to be passed to them - but you write wrappers for those, and do (for example) JSON encoding/decoding at each end.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951708]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2017-12-13 02:29 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (344 votes). Check out past polls.