Hello,
I would like to use a java API from Perl. The API is pretty complex and I'm
not sure Inline is right thing to do this...?
I read some documentation and did some attemps, but still get only error mesage.
I am begginer with Perl, Java and haven't used the API before, so it's hard
to find what's wrong....(There's propably problem in crosslinked classes. I
used AUTOSTUDY, but still no succes...)
Appreciate any help.
My first attemp was:
#!/usr/bin/perl -w
use strict; use warnings;
BEGIN {
$ENV{CLASSPATH}.=":./antlr.jar:./jena.jar:./xercesImpl.jar:./concurrent.jar:./junit.jar:./xmlParserAPIs.jar:./icu4j.jar:./log4j-1.2.7.jar:./jakarta-oro-2.0.5.jar:./rdf-api-2001-01-19.jar";
}
print "Script is running...\n";
use Inline Java => "STUDY",
PORT => 7890,
AUTOSTUDY => 1,
STUDY => ['com.hp.hpl.jena.Jena'];
print "Testing JENA2 API funcionality\n";
my $OntModel = com.hp.hpl.jena.rdf.model.ModelFactory->createOntologyModel();
print "END\n";
but got error message:
Bareword "com" not allowed while "strict subs" in use at faq2.cgi line 19, <GEN9> line
4.
.
.
Eexecution of faq2.cgi aborted due to compilation errors.
(in cleanup) In method DESTROY of class main::com::hp::hpl::jena::Jena: Can't
find object 0 for thread
IJST-#0 at /home/xmalach1/diplomka/ss2/pmodules/Inline/Java/Object.pm line 345
at faq2.cgi line 0
(in cleanup) Unknown Java object reference
main::com::hp::hpl::jena::Jena=HASH(0x82f0cec) at faq2.cgi
line 0
So I was trying to get right Java Classes via import:
#!/usr/bin/perl -w
use strict; use warnings;
#paths to each file of librari
BEGIN {
$ENV{CLASSPATH}.=':./antlr.jar:./jena.jar:./xercesImpl.jar:./concurrent.jar:./junit.jar:./xmlParserAPIs.jar:./icu4j.jar:./log4j-1.2.7.jar:./jakarta-oro-2.0.5.jar:./rdf-api-2001-01-19.jar:.';
}
print "Script is running...\n";
use Inline Java => <<'EOJ', AUTOSTUDY => 1, PORT=>7890, CLASSPATH => "./";
import java.io.PrintStream;
import java.util.*;
import java.util.Iterator; // to this everything OK
import com.hp.hpl.jena.ontology.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.shared.PrefixMapping;
//... will be more
EOJ
print "Testing JENA2 API funcionality\n";
my $OntModel = com.hp.hpl.jena.rdf.model.ModelFactory->createOntologyModel();
print "END\n";
but got another error message:
A problem was encountered while attempting to compile and install your
Inline Java code. The command that failed was:
"/packages/run/j2sdk-1.4.2_02/bin/javac" -d
"/home/xmalach1/public_html/diplomka/ss2/_Inline/lib/auto/faq1_cgi_ae35"
faq1_cgi_ae35.java > cmd.out 2>&1
The build directory was:
/home/xmalach1/public_html/diplomka/ss2/_Inline/build/faq1_cgi_ae35
The error message was:
faq1_cgi_ae35.java:6: package com.hp.hpl.jena.ontology does not exist
import com.hp.hpl.jena.ontology.*;
Thanks,
Jan Malach