Building a java library
Friday, 6 September 2013 · 3 messages
JT
Joe Templeman6 Sep 2013 05:17 #
Hi, I'm new to basex and I'm trying to build an external java library which will return a list of documents for me to then query, but I'm running into a problem where it can't seem to find the class.
This is the script I'm running:
declare namespace t = "java:com.inkling.modules.Test";
let $loader := t:new("local")
return (
t:fileNames($loader)
)In my root project directory I have a subdirectory for my java files so I start up the baseX gui using
java -cp "BaseX76.jar:xmldblib/src/" org.basex.BaseXGUIand my java file (in xmldblib/src/com/inkling/modules/Test.java looks like:
public class Test {
String env;
public Test(String environment) {
env = environment;
}
public List<String> fileNames() { ...... }
}When I try and run the xquery script, it just says Unknown Constructor Test.new(xs:string)
Does anybody have an idea what I'm doing wrong? Any help is appreciated.
Thanks,
Joe
DP
Dimitar Popov6 Sep 2013 15:11 #
Quoted text · Joe Templeman · 19 lines
On Thu, 2013-09-05 at 18:17 -0700, Joe Templeman wrote: > Hi, I'm new to basex and I'm trying to build an external java library > which will return a list of documents for me to then query, but I'm > running into a problem where it can't seem to find the class. > > > This is the script I'm running: > > > declare namespace t = "java:com.inkling.modules.Test"; > let $loader := t:new("local") > return ( > t:fileNames($loader) > ) > In my root project directory I have a subdirectory for my java files > so I start up the baseX gui using > > > java -cp "BaseX76.jar:xmldblib/src/" org.basex.BaseXGUI
Is the file Test.class with the compiled byte code in src? Normally one keeps the source files there.
Quoted text · Joe Templeman · 3 lines
> and my java file (in xmldblib/src/com/inkling/modules/Test.java looks > like: >
Is this complete content of the file? The package declaration and the import statements are missing.
Quoted text · Joe Templeman · 15 lines
> public class Test { > String env; > > > public Test(String environment) { > env = environment; > } > > > public List<String> fileNames() { ...... } > } > > > When I try and run the xquery script, it just says Unknown Constructor > Test.new(xs:string)
This example works fine for me.
Regards,
Dimitar
JT
Joe Templeman6 Sep 2013 21:29 #
Aha, you were absolutely right, even though there were some .class files in my src folder, IntelliJ was building them to out/production/. I updated my classpath and it found them properly.
Now the java is running it's raising an exception, where does the java logging go so I can dig into the errors?
Thanks for the help,
Joe
Quoted text · Joe Templeman · 57 lines
On Fri, Sep 6, 2013 at 6:11 AM, Dimitar Popov <dp at basex.org> wrote: > On Thu, 2013-09-05 at 18:17 -0700, Joe Templeman wrote: > > Hi, I'm new to basex and I'm trying to build an external java library > > which will return a list of documents for me to then query, but I'm > > running into a problem where it can't seem to find the class. > > > > > > This is the script I'm running: > > > > > > declare namespace t = "java:com.inkling.modules.Test"; > > let $loader := t:new("local") > > return ( > > t:fileNames($loader) > > ) > > In my root project directory I have a subdirectory for my java files > > so I start up the baseX gui using > > > > > > java -cp "BaseX76.jar:xmldblib/src/" org.basex.BaseXGUI > > Is the file Test.class with the compiled byte code in src? Normally one > keeps the source files there. > > > and my java file (in xmldblib/src/com/inkling/modules/Test.java looks > > like: > > > Is this complete content of the file? The package declaration and the > import statements are missing. > > > public class Test { > > String env; > > > > > > public Test(String environment) { > > env = environment; > > } > > > > > > public List<String> fileNames() { ...... } > > } > > > > > > When I try and run the xquery script, it just says Unknown Constructor > > Test.new(xs:string) > > This example works fine for me. > > Regards, > Dimitar > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
Written for BaseX 7.7. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery