A couple of emails later to the folks at inline@perl.org and some poking around of my own I found the solution. Part A is to make sure the class path gets set correctly and includes not only the jar that I want to use but anything the jar references.
Secondly, just because I've got the class path correct does not mean that it will totally understand the object that you are calling in. Use the study export from Inline::Java to cause it to "study" the object and bind it to Perl.
The end result code looks like:
Now if I could only remember why I started down this path... Eh... need more coffee.#!/usr/bin/perl -w BEGIN { my $libdir='/home/pberghol/src/www.bayshoredogclub.org/WebRoot/WEB +-INF/lib'; my @jars=(); opendir LIBDIR,$libdir or die $1; while( my $fname = readdir(LIBDIR)){ next unless $fname =~ m@\.jar$@; push @jars,$libdir . "/" . $fname; } $ENV{CLASSPATH}=join(":",@jars,"/home/pberghol/tmp/bcdchbm.jar"); } use Inline Java => << 'End_Of_Java_Code' ,CLASSPATH=> $ENV{CLASSPATH}; import org.bcdc.hbm.services.PeopleService; class FooBar { public FooBar(){ } public PeopleService getPersonService() { return PeopleService.getInstance(); } } End_Of_Java_Code use Inline::Java qw(study_classes); use Data::Dumper; study_classes(['org.bcdc.hbm.services.PeopleService']); my $foo = new FooBar(); my $psvc = $foo->getPersonService(); print Dumper($psvc); printf "%s\n",$psvc->getPersonNameFromID(1); print Dumper($foo);
In reply to SOLUTION (was Re: Inline::Java and jar files?)
by blue_cowdawg
in thread Inline::Java and jar files?
by blue_cowdawg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |