Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Inline::Java Question

by wpflum (Initiate)
on Jan 19, 2012 at 18:29 UTC ( #948832=perlquestion: print w/ replies, xml ) Need Help??
wpflum has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to use a vendor driver written in Java with a perl program. I've never used java but I have done a bit of perl programming. After looking around the web a bit I found a site, http://www.perl.com/pub/2003/11/07/java.html, that shows using a perl package to wrap the java in an Inline code to let you use it it perl. I tried the sample package with my jar file and then tried to access it like the example showed in another perl file but I'm getting all kinds of errors. I eventually discovered I had to add the CLASSPATH directly with the entire path/filename to get by some of the errors but when ever I try to access the java class I get a undefined subroutine. Is there any other tutorials on using Inline::Java in perl with a jar file or can someone point me in the right direction?? Is the sample package file the website uses the correct way to return the java object in the first place?? Help

Comment on Inline::Java Question
Re: Inline::Java Question
by tobyink (Abbot) on Jan 19, 2012 at 21:33 UTC

    I used it in XML::Saxon::XSLT2. Try using that (you'll need the Java Saxon XSLT library) and see where it gets you.

    It's a while since I wrote that, but I'd be happy to answer any specific questions.

      Your code itself didn't help but it showed me that I needed to look into the INLINE parts first so I dug into the INLINE help and pretty much got the interface working. I am having another problem though, I need to use a java IMAGE object in the code I'm writing. What I need to do is read in an image file and pass it to the java driver. To do this when I couldn't figure out the actual format of the IMAGE object I wrote a small java class than imported the java IMAGE handling routines and let me get the IMAGE object in return for giving it the filename. I made sure this worked by dropping it into the original java test program given to me by the hardware company and the concept works just like it should. Now I used INLINE Java to use the class I made to read in the image file into a variable but when I try to send the variable to the java class that handles the hardware interface I'm getting the following error.

      main::java::lang::IllegalArgumentException=HASH(0x9a82f58)

      I'm guessing that something doesn't like the format being returned from the class to read the file but I'm not sure what I can do to force this to work. Any Ideas?
        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??

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://948832]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-07-13 21:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (252 votes), past polls