Hi guys,

I have problem with Inline:java study, please help.

What I want to do is that I have a java package, I want to instantiate
object using one of the classes from the package directly from Perl. So I
guess I can just use the "study" in inline:java. I am using Windows XP.

I try it out with an example from:
http://search.cpan.org/~patl/Inline-Java-0.32/Java.pod#STUDYING
but it didn't work. 

Here's code in two files:
--------------
user_script.pl
--------------
#!/usr/bin/perl -w
require 5.006;

use PDMLib;

$warn = PDMLib->startWARN();
if($warn > 0)
{
   print "Error starting WARN.\n";
   exit(1);
}

print "WARN started.\n";

----------
PDMLib.pm
----------
package PDMLib;
use strict;
use warnings;

use Inline (
  Java => 'STUDY',
  STUDY => ['java.util.HashMap'],
) ;

sub startWARN()
{
   my $hm = new java::util::HashMap() ;
   $hm->put("key", "value") ;
   my $val = $hm->get("key") ;
   print($val . "\n") ; # prints value  
}

1;

===========================
I get this error:
Can't locate object method "new" via package "java::util::HashMap"
(perhaps you
forgot to load "java::util::HashMap"?) at PDMLib.pm line 17, <GEN7> line 4.

Can somebody please kindly tell me why?

Reply via email to