Finally got blipkit started from java via jpl

Finally got blipkit started from java via jpl :)

  • (Thanks to Andrew Koster on the SWIPL mailing list, who made me continue researching the LD_PRELOAD trick!)

In order to get the jpl java examples to work, LD_LIBRARY_PATH has to contain:

/usr/lib/jvm/java-1.5.0-sun-1.5.0.19/jre/lib/i386/client/:/usr/lib/jvm/java-1.5.0-sun-1.5.0.19/jre/lib/i386/

Furthermore, CLASSPATH has to be:
/usr/local/lib/pl-5.7.15/lib/jpl.jar:/home/samuel/install/swi-prolog/pl57/packages/jpl/examples/java/Test

Now firing up blipkit works, when calling Java from commandline!!! :).

Running the command:

LD_PRELOAD=/usr/local/lib/pl-5.7.15/lib/i686-linux/libjpl.so java -Djava.library.path=/usr/local/lib/pl-5.7.15/lib/i686-linux/ Test

... I get:

-G0
-A0
-T0
-g
main
-t
halt
-s
/home/samuel/blipstart.pl
% library(swi_hooks) compiled into pce_swi_hooks 0.00 sec, 2,060 bytes
% /home/samuel/.plrc compiled 0.00 sec, 704 bytes
%   bio(bioprolog_util) compiled into bioprolog_util 0.01 sec, 42,180 bytes
%     bio(mode) compiled into mode 0.00 sec, 7,788 bytes
%    bio(dbmeta) compiled into dbmeta 0.04 sec, 244,516 bytes
%       library(option) compiled into swi_option 0.00 sec, 8,640 bytes
%      library(sgml) compiled into sgml 0.01 sec, 41,308 bytes
%        library(quintus) compiled into quintus 0.01 sec, 11,552 bytes
%       rewrite compiled into rewrite 0.01 sec, 17,668 bytes
%       library(uri) compiled into uri 0.00 sec, 5,940 bytes
%       library(record) compiled into record 0.01 sec, 15,332 bytes
%      rdf_parser compiled into rdf_parser 0.03 sec, 74,800 bytes
%       library(gensym) compiled into gensym 0.00 sec, 2,436 bytes
%      rdf_triple compiled into rdf_triple 0.00 sec, 19,132 bytes
%     library(rdf) compiled into rdf 0.04 sec, 153,032 bytes
%      library(assoc) compiled into assoc 0.00 sec, 12,104 bytes
%     library(sgml_write) compiled into sgml_write 0.01 sec, 51,600 bytes
%     library(nb_set) compiled into nb_set 0.00 sec, 3,216 bytes
%     rdf_cache compiled into rdf_cache 0.00 sec, 8,592 bytes
%    library(semweb/rdf_db) compiled into rdf_db 0.09 sec, 309,936 bytes
%       library(utf8) compiled into utf8 0.01 sec, 7,200 bytes
%      library(url) compiled into url 0.02 sec, 61,000 bytes
%      library(readutil) compiled into read_util 0.01 sec, 8,800 bytes
%      library(socket) compiled into socket 0.00 sec, 5,608 bytes
%      library(base64) compiled into base64 0.00 sec, 9,156 bytes
%     library(http/http_open) compiled into http_open 0.04 sec, 108,672 bytes
%     library(date) compiled into date 0.00 sec, 9,508 bytes
%    library(semweb/rdf_http_plugin) compiled into rdf_http_plugin 0.04 sec, 124,608 bytes
%   bio(io) compiled into io 0.19 sec, 737,684 bytes
%   bio(metadata_db) compiled into metadata_db 0.01 sec, 16,688 bytes
%   bio(blipkit_shell_dcg) compiled into blipkit_shell_dcg 0.00 sec, 4,600 bytes
%   bio(tabling) compiled into tabling 0.00 sec, 9,488 bytes
%  bio(blipkit) compiled into blipkit 0.23 sec, 862,060 bytes
%    bio(graph) compiled into graph 0.01 sec, 18,220 bytes
%    bio(macros_transitive) compiled into macros_transitive 0.00 sec, 3,516 bytes
%   bio(ontol_db) compiled into ontol_db 0.04 sec, 113,000 bytes
%    bio(stats_distributions) compiled into stats_distributions 0.01 sec, 25,396 bytes
%   bio(curation_db) compiled into curation_db 0.02 sec, 58,088 bytes
%     bio(textmatch) compiled into textmatch 0.00 sec, 5,296 bytes
%    bio(macros_lookup) compiled into macros_lookup 0.00 sec, 9,152 bytes
%   bio(ontol_lookup) compiled into ontol_lookup 0.00 sec, 16,924 bytes
%   bio(ontol_writer) compiled into ontol_writer 0.01 sec, 1,016 bytes
%   bio(ontol_writer_text) compiled into ontol_writer_text 0.00 sec, 20,660 bytes
%       library(rbtrees) compiled into rbtrees 0.01 sec, 45,648 bytes
%      library(thread_pool) compiled into thread_pool 0.02 sec, 66,712 bytes
%        library(memfile) compiled into memory_file 0.00 sec, 3,900 bytes
%         library(broadcast) compiled into broadcast 0.00 sec, 3,988 bytes
%        library(settings) compiled into settings 0.00 sec, 24,568 bytes
%        dcg_basics compiled into dcg_basics 0.00 sec, 11,964 bytes
%         library(pairs) compiled into pairs 0.00 sec, 4,380 bytes
%        html_write compiled into html_write 0.02 sec, 61,332 bytes
%        http_exception compiled into http_exception 0.00 sec, 3,716 bytes
%        mimetype compiled into mimetype 0.00 sec, 6,512 bytes
%        mimepack compiled into mime_pack 0.00 sec, 5,572 bytes
%       http_header compiled into http_header 0.06 sec, 193,528 bytes
%       http_stream compiled into http_stream 0.00 sec, 3,988 bytes
%      http_wrapper compiled into httpd_wrapper 0.07 sec, 211,776 bytes
%     library(http/thread_httpd) compiled into thread_httpd 0.10 sec, 301,516 bytes
%     library(http/http_session) compiled into http_session 0.00 sec, 14,852 bytes
%     bio(xml_writer) compiled into xml_writer 0.01 sec, 8,124 bytes
%    bio(serval) compiled into serval 0.12 sec, 377,788 bytes
%   bio(ontol_writer_obo) compiled into ontol_writer_obo 0.13 sec, 426,512 bytes
%  bio(blipkit_ontol) compiled into blipkit_ontol 0.23 sec, 747,860 bytes
%     library(oset) compiled into oset 0.00 sec, 8,264 bytes
%    library(ordsets) compiled into ordsets 0.01 sec, 17,120 bytes
%   bio(phylo_db) compiled into phylo_db 0.03 sec, 106,012 bytes
%  bio(blipkit_phylo) compiled into blipkit_phylo 0.03 sec, 118,896 bytes
%   bio(fasta_db) compiled into fasta_db 0.00 sec, 1,812 bytes
%    bio(gencode) compiled into gencode 0.03 sec, 87,032 bytes
%    bio(suffixtree) compiled into suffixtree 0.00 sec, 19,216 bytes
%    bio(iupac) compiled into iupac 0.01 sec, 2,764 bytes
%   bio(bioseq) compiled into bioseq 0.04 sec, 126,644 bytes
%  bio(blipkit_fasta) compiled into blipkit_fasta 0.05 sec, 137,536 bytes
%   bio(sb_db) compiled into sb_db 0.00 sec, 12,268 bytes
%  bio(blipkit_sb) compiled into blipkit_sb 0.01 sec, 29,616 bytes
%    library(http/http_client) compiled into http_client 0.01 sec, 17,264 bytes
%   bio(web_fetch) compiled into web_fetch 0.02 sec, 21,792 bytes
%    bio(xml_transform) compiled into xml_transform 0.01 sec, 18,572 bytes
%   bio(web_fetch_google) compiled into web_fetch_google 0.01 sec, 36,604 bytes
%   bio(web_fetch_yahoo) compiled into web_fetch_yahoo 0.00 sec, 3,140 bytes
%   bio(web_fetch_ncbi) compiled into web_fetch_ncbi 0.01 sec, 8,464 bytes
%   bio(web_search_expander) compiled into web_search_expander 0.00 sec, 11,608 bytes
%  bio(blipkit_web) compiled into blipkit_web 0.05 sec, 136,152 bytes
% /home/samuel/blipstart.pl compiled 0.63 sec, 2,072,576 bytes
test 0...% test.pl compiled 0.00 sec, 2,220 bytes
passed.
test 1...passed.
test 2...passed.
test 3...passed.
test 4...passed.
test 5...passed.
test 6...passed.
test 7...passed.
test 8...passed.
test 9...passed.
test 10...passed.
test 11...passed.
test 101...00000000000000000000111111111111111111112222222222222222222233333333333333333333444444444444444444445555555555555555555566666666666666666666777777777777777777778888888888888888888899999999999999999999passed.

The content of the Test.java is (I modified it to enforce loading blipkit):

//tabstop=4
//*****************************************************************************/
// Project: jpl
//
// File:    $Id$
// Date:    $Date$
// Author:  Fred Dushin <fadushin@syr.edu>
//          
//
// Description:
//    
//
// -------------------------------------------------------------------------
// Copyright (c) 1998 Fred Dushin
//                    All rights reserved.
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Library Public License for more details.
//*****************************************************************************/
 
 
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
 
import java.util.Hashtable;
import jpl.Query;                // empirically, we need this, but I don't know why...
import jpl.PrologException;
import jpl.*;
 
public class Test
{
    public static void
    main( java.lang.String argv[] )
    {
            String[] blipInitFile;
 
            blipInitFile = readFileToStringArray("/home/samuel/blipstart");
            for (int i=1; i<blipInitFile.length; i++) {
                if (blipInitFile[i] != null) {
                    System.out.println(blipInitFile[i]);
                }
            }
 
        JPL.setDefaultInitArgs(blipInitFile);
 
 
         JPL.init();                // we don't need this with the current JPL (lazy init-on-demand)
 
        run_tests();
    }
 
 
 
    public static String[] readFileToStringArray(String filePath) {
        File file = new File(filePath);
        FileInputStream fis = null;
        BufferedInputStream bis = null;
        DataInputStream dis = null;
        List<String> stringBuffer = new ArrayList<String>();
 
        try {
          fis = new FileInputStream(file);
 
          // Here BufferedInputStream is added for fast reading.
          bis = new BufferedInputStream(fis);
          dis = new DataInputStream(bis);
 
          // dis.available() returns 0 if the file does not have more lines.
          int i = 0;
          while (dis.available() != 0) {
              stringBuffer.add(dis.readLine());
          }
 
          // dispose all the resources after using them.
          fis.close();
          bis.close();
          dis.close();
 
        } catch (FileNotFoundException e) {
          e.printStackTrace();
        } catch (IOException e) {
          e.printStackTrace();
        }
 
        String[] result = stringBuffer.toArray(new String[]{});
        return result;
    }
 
 
 
 
    static void
    run_tests()
    {
        test_0();
        test_1();
        test_2();
        test_3();
        test_4();
        test_5();
        test_6();
        test_7();
        test_8();
        test_9();
        test_10();
        test_11();
 
        test_101();
    }
 
    static void
    test_0()
    {
        System.out.print( "test 0..." );
 
 
        Query query = 
            new Query("consult('test.pl')");
 
        if ( !query.hasSolution() ){
            System.out.println( "consult('test.pl') failed" );
            System.exit( 1 );
        }
        System.out.println( "passed." );
    }
 
    static Term a = 
        new Atom( "a" );
    static Term b = 
        new Atom( "b" );
    static Term f_a = 
        new Compound(
            "f",
            new Term[] {a}
        );
    static Term pair_a_b =
        new Compound(
            "-",
            new Term[] {a,b}
        );
 
    static void
    test_1()
    {
        System.out.print( "test 1..." );
        Query query = 
            new Query("p(a)");
 
        if ( !query.hasSolution() ){
            System.out.println( "p(a) failed" );
            System.exit( 1 );
        }
        System.out.println( "passed." );
    }
 
    static void
    test_2()
    {
        System.out.print( "test 2..." );
        Query query = 
            new Query( 
                "p", 
                new Term[] {f_a}
            );
 
        if ( !query.hasSolution() ){
            System.out.println( "p(f(a)) failed" );
            System.exit( 1 );
        }
        System.out.println( "passed." );
    }
 
    static void
    test_3()
    {
        System.out.print( "test 3..." );
        Query query = 
            new Query( 
                "p", 
                new Term[] {pair_a_b}
            );
 
        if ( !query.hasSolution() ){
            System.out.println( "p( a-b ) failed" );
            System.exit( 1 );
        }
        System.out.println( "passed." );
    }
 
    static void
    test_4()
    {
        System.out.print( "test 4..." );
        Variable X = new Variable("X");
        Query query = 
            new Query( 
                "p", 
                new Term[] {X}
            );
 
        Term[] target = new Term[] {a,f_a,pair_a_b,new Variable("_")};
 
        Hashtable[] solutions = query.allSolutions();
 
        if ( solutions.length != 4 ){
            System.out.println( "p(X) failed:" );
            System.out.println( "\tExpected: 4 solutions" );
            System.out.println( "\tGot:      " + solutions.length );
            System.exit( 1 );
        }
 
        for ( int i = 0;  i < solutions.length-1;  ++i ){
            Term binding = (Term)solutions[i].get( "X" );
            if ( ! binding.equals( target[i] ) ){
                System.out.println( "p(X) failed" );
                System.out.println( "\tExpected: " + target[i]);
                System.out.println( "\tGot:      " + binding);
                System.exit( 1 );
            }
        }
 
        System.out.println( "passed." );
    }
 
    static void
    test_5()
    {
        System.out.print( "test 5..." );
        Variable X = new Variable("X");
        Variable Y = new Variable("Y");
        Query query = 
            new Query( 
                "p", 
                new Term[] {X,Y}
            );
 
        Term[] x_target = new Term[] {a,a};
        Term[] y_target = new Term[] {a,b};
 
        Hashtable[] solutions = query.allSolutions();
 
        if ( solutions.length != 2 ){
            System.out.println( "p(X, Y) failed:" );
            System.out.println( "\tExpected: 2 solutions" );
            System.out.println( "\tGot:      " + solutions.length );
            System.exit( 1 );
        }
 
        for ( int i = 0;  i < solutions.length;  ++i ){
            Object x_binding = solutions[i].get("X");
            if ( ! x_binding.equals( x_target[i] ) ){
                System.out.println( "p(X, Y) failed:" );
                System.out.println( "\tExpected: " + x_target[i] );
                System.out.println( "\tGot:      " + x_binding );
                System.exit( 1 );
            } 
            Object y_binding = solutions[i].get("Y");
            if ( ! y_binding.equals( y_target[i] ) ){
                System.out.println( "p( X, Y ) failed:" );
                System.out.println( "\tExpected: " + y_target[i] );
                System.out.println( "\tGot:      " + y_binding );
                System.exit( 1 );
            } 
        }
        System.out.println( "passed." );
    }
 
    static void
    test_6()
    {
        System.out.print( "test 6..." );
        Variable X = new Variable("X");
        Query query = 
            new Query( 
                "p", 
                new Term[] {X,X}
            );
 
        Term[] x_target = new Term[] {a};
 
        Hashtable[] solutions = query.allSolutions();
 
        if ( solutions.length != 1 ){
            System.out.println( "p(X, X) failed:" );
            System.out.println( "\tExpected: 1 solution" );
            System.out.println( "\tGot:      " + solutions.length );
            System.exit( 1 );
        }
 
        for ( int i = 0;  i < solutions.length;  ++i ){
            Object x_binding = solutions[i].get("X");
            if ( ! x_binding.equals( x_target[i] ) ){
                System.out.println( "p(X, X) failed:" );
                System.out.println( "\tExpected: " + x_target[i] );
                System.out.println( "\tGot:      " + x_binding );
                System.exit( 1 );
            }
        }
        System.out.println( "passed." );
    }
 
    static void
    test_7()
    {
        System.out.print( "test 7..." );
        Variable X = new Variable("X");
        Variable Y = new Variable("Y");
        Query query = 
            new Query( 
                "r", 
                new Term[] {
                    new Compound(
                        "f",
                        new Term[] {X,X}
                    ), 
                    Y
                }
            );
 
        Hashtable[] solutions = query.allSolutions();
 
        if ( solutions.length != 2 ){
            System.out.println( "r(f(X,X), Y) failed:" );
            System.out.println( "\tExpected: 2 solutions" );
            System.out.println( "\tGot:      " + solutions.length );
            System.exit( 1 );
        }
 
        Object x_binding, y_binding;
 
        x_binding = solutions[0].get("X");
        y_binding = solutions[0].get("Y");
        if ( x_binding != y_binding ){
            System.out.println( "r(f(X,X), Y) failed:" );
            System.out.println( Util.toString( solutions[0] ) );
            System.out.println( "\tThe variables to which X and Y are bound in the first solution should be identical." );
            System.exit( 1 );
        }
 
        x_binding = solutions[1].get("X");
        y_binding = solutions[1].get("Y");
        if ( x_binding == y_binding ){
            System.out.println( "r(f(X,X), Y) failed:" );
            System.out.println( Util.toString( solutions[1] ) );
            System.out.println( "\tThe variables to which X and Y are bound in the second solution should be distinct." );
            System.exit( 1 );
        }
        if ( x_binding.equals( y_binding ) ){
            System.out.println( "r(f(X,X), Y) failed:" );
            System.out.println( Util.toString( solutions[1] ) );
            System.out.println( "\tThe variables to which X and Y are bound in the second solution should not be \"equal\"." );
            System.exit( 1 );
        }
        /*
        if ( ! solutions[0].get("X").equals( solutions[1].get("X") ) ){
            System.out.println( "r(f(X,X), Y) failed:" );
            System.out.println( Util.toString( solutions[0] ) );
            System.out.println( 
                "\tThe variable to which X is bound in the first solution (" + solutions[0].get("X") + ")\n" +
                "\tshould be equal to the variable to which X is bound in the second (" + solutions[1].get("X") + ")");
            System.exit( 1 );
        }
         */
        System.out.println( "passed." );
    }
 
    static void
    test_8()
    {
        System.out.print( "test 8..." );
        Variable X = new Variable("X");
        Query query = 
            new Query( 
                "r", 
                new Term[] {
                    new Compound(
                        "f",
                        new Term[] {X,X}
                    ), 
                    X
                }
            );
 
        Hashtable[] solutions = query.allSolutions();
 
        if ( solutions.length != 2 ){
            System.out.println( "r( f( X, X ), X ) failed:" );
            System.out.println( "\tExpected: 2 solutions" );
            System.out.println( "\tGot:      " + solutions.length );
            System.exit( 1 );
        }
        /*
        if ( ! solutions[0].get("X").equals( solutions[1].get("X") ) ){
            System.out.println( "r( f( X, X ), X ) failed:" );
            System.out.println( Util.toString( solutions[0] ) );
            System.out.println( 
                "\tThe variable to which X is bound in the first solution\n" +
                "\tshould be equal to the variable to which X is bound in the second." );
            System.exit( 1 );
        }
         */
        System.out.println( "passed." );
    }
 
    // corresponds with Prolog List: [a-a,a-b]
    static Term test_9_solution =
        Util.termArrayToList(
            new Term[] {
                new Compound( "-", new Term[] {a,a}),
                new Compound( "-", new Term[] {a,b})
            }
        );
 
    static void
    test_9()
    {
        System.out.print( "test 9..." );
        Variable X   = new Variable("X");
        Variable Y   = new Variable("Y");
        Variable XYs = new Variable("XYs");
        Query query = 
            new Query( 
                "bagof", 
                new Term[] { 
                    new Compound(
                        "-",
                        new Term[] {X,Y}
                    ),
                    new Compound(
                        "p",
                        new Term[] {X,Y}
                    ), 
                    XYs
                }
            );
 
        Hashtable[] solutions = query.allSolutions();
 
        if ( solutions.length != 1 ){
            System.out.println( "bagof(X-Y, p(X,Y), XYs) failed:" );
            System.out.println( "\tExpected: 1 solution" );
            System.out.println( "\tGot:      " + solutions.length );
            System.exit( 1 );
        }
 
        Term term = (Term) solutions[0].get("XYs");
 
     //    if ( ! (term instanceof List) ){
        if ( ! (term instanceof Compound && ".".equals(((Compound)term).name()) && ((Compound)term).arity()==2) ){
            System.out.println( "bagof(X-Y, p(X,Y), XYs) failed:" );
            System.out.println( "\tExpected: XYs to be a List" );
            System.out.println( "\tGot:      " + term );
            System.exit( 1 );
        }
 
        if ( ! term.equals( test_9_solution ) ){
            System.out.println( "bagof(X-Y, p(X,Y), XYs) failed:" );
            System.out.println( "\tExpected: " + test_9_solution );
            System.out.println( "\tGot:      " + term );
            System.exit( 1 );
        }
 
        System.out.println( "passed." );
    }
 
    static void
    test_10()
    {
        System.out.print( "test 10..." );
        Query query = 
            new Query( "t" );
 
        try {
            boolean b = query.hasSolution();
            System.out.println( "t failed:" );
            System.out.println( "\tExpected: JPLException" );
            System.out.println( "\tGot: " + b );
            System.exit( 1 );
        } catch ( PrologException e ){
        }
 
        System.out.println( "passed." );
    }
 
    static void
    test_11()
    {
        System.out.print( "test 11..." );
        Term tuple =
            new Compound(
                "t",
                new Term[]{
                    new Atom( "a" ),
                    new Atom( "b" ),
                    new Atom( "c" ),
                    new Atom( "d" ),
                    new Atom( "e" )
                }
            );
 
        try {
            Variable  X = new Variable("X");
            Query query = new Query( "tuple", new Term[] {X} );
 
            java.util.Hashtable solution = query.oneSolution();
 
            Term result = (Term) solution.get("X");
 
            if ( result == null || ! result.equals( tuple ) ){
                System.out.println( "failed:" );
                System.out.println( "\tresult: " + result );
                System.out.println( "\ttuple:  " + tuple );
                System.exit( 1 );
            }
 
            Term term;
 
            term = new Atom( "a" );
            if ( ((Compound)result).arg( 1 ) == null || !((Compound)result).arg( 1 ).equals( term ) ){
                System.out.println( "failed:" );
                System.out.println( "\t((Compound)result).arg( 1 ): " + ((Compound)result).arg( 1 ) );
                System.out.println( "\tterm           : " + term );
                System.exit( 1 );
            }
            term = new Atom( "b" );
            if ( ((Compound)result).arg( 2 ) == null || !((Compound)result).arg( 2 ).equals( term ) ){
                System.out.println( "failed:" );
                System.out.println( "\t((Compound)result).arg( 2 ): " + ((Compound)result).arg( 2 ) );
                System.out.println( "\tterm           : " + term );
                System.exit( 1 );
            }
            term = new Atom( "e" );
            if ( ((Compound)result).arg( 5 ) == null || !((Compound)result).arg( 5 ).equals( term ) ){
                System.out.println( "failed:" );
                System.out.println( "\t((Compound)result).arg( 5 ): " + ((Compound)result).arg( 5 ) );
                System.out.println( "\tterm           : " + term );
                System.exit( 1 );
            }
            // arg0(6) throws an exception, as I'd expect it to...
         //    if ( ((Compound)result).arg( 7 ) != null ){
         //        System.out.println( "failed:" );
         //        System.out.println( "\t((Compound)result).arg( 7 ): " + ((Compound)result).arg( 7 ) );
         //        System.out.println( "\tshould be null" );
         //        System.exit( 1 );
         //    }
        } catch ( PrologException e ){
            System.out.println( "failed" );
            e.printStackTrace();
            System.exit( 1 );
        }
 
        System.out.println( "passed." );
    }
 
    static void
    test_101()
    {
        System.out.print( "test 101..." );
        Thread[] threads = new Thread[10];
 
        for ( int i = 0;  i < threads.length;  ++i ){
            threads[i] = new QueryThread( i );
        }
        for ( int i = 0;  i < threads.length;  ++i ){
            threads[i].start();
        }
        for ( int i = 0;  i < threads.length;  ++i ){
            try {
                threads[i].join();
            } catch ( InterruptedException ie ){
                ie.printStackTrace();
                System.exit( 1 );
            }
        }
        System.out.println( "passed." );
    }
 
    private static class
    QueryThread extends Thread
    {
        private int id_ = -1;
 
        public 
        QueryThread( int id )
        {
            this.id_ = id;
        }
 
        public java.lang.String
        toString()
        {
            return "(QueryThread id=" + id_ + ")";
        }
 
 
        public void
        run()
        {
            Query query = 
                new Query( 
                    "p",
                    new Term[] {
                        new Atom("a"),
                        new Atom("a")
                    }
                );
 
            for ( int i = 0;  i < 10;  ++i ){
                try {
                    query.hasSolution();
                } catch ( jpl.JPLException e ){
                    System.out.println( "Threaded p( a, a ) threw exception: " + e);
                    System.exit( 1 );
                }
                System.out.print( id_ );
                Thread.yield();
            }
            for ( int i = 0;  i < 10;  ++i ){
             //    synchronized ( Query.lock() ){
                    try {
                        while ( query.hasMoreSolutions() ){
                            Thread.yield();
                            query.nextSolution();
                        }
                    } catch ( jpl.JPLException e ){
                        System.out.println( "Threaded p( a, a ) threw exception: " + e);
                        System.exit( 1 );
                    }
                    System.out.print( id_ );
             //    }
            }
        }
    }
 
 
    // more to come??
}

Furthermore, for startup, the two files

  • ~/blipstart
  • ~/blipstart.pl are used. Here are the contents of them:

Contents of ~/blipstart

-L0
-G0
-A0
-T0
-g
main
-t
halt
-s
/home/samuel/blipstart.pl

Contents of ~/blipstart.pl

user:file_search_path(bio, blipkit(attic)).
user:file_search_path(bio, blipkit(biblio)).
user:file_search_path(bio, blipkit(bionlp)).
user:file_search_path(bio, blipkit(blipcore)).
user:file_search_path(bio, blipkit(curation)).
user:file_search_path(bio, blipkit(genomic)).
user:file_search_path(bio, blipkit(homol)).
user:file_search_path(bio, blipkit(metadata)).
user:file_search_path(bio, blipkit(obolog)).
user:file_search_path(bio, blipkit(omim)).
user:file_search_path(bio, blipkit(ontograph)).
user:file_search_path(bio, blipkit(ontol)).
user:file_search_path(bio, blipkit('ontol/thea')).
user:file_search_path(bio, blipkit(pheno)).
user:file_search_path(bio, blipkit(phylo)).
user:file_search_path(bio, blipkit(rdft)).
user:file_search_path(bio, blipkit(sb)).
user:file_search_path(bio, blipkit(serval)).
user:file_search_path(bio, blipkit(sql)).
user:file_search_path(bio, blipkit(stats)).
user:file_search_path(bio, blipkit(structure)).
user:file_search_path(bio, blipkit(variation)).
user:file_search_path(bio, blipkit(web)).
user:file_search_path(bio, blipkit(xml)).
:- use_module(bio(blipkit)).
:- use_module(bio(blipkit_ontol)).
:- use_module(bio(blipkit_phylo)).
:- use_module(bio(blipkit_fasta)).
:- use_module(bio(blipkit_sb)).
:- use_module(bio(blipkit_web)).

Comments

Just a sidenote, that I

Just a sidenote, that I needed to store somewhere, about the dependencies for blipkit:

  • go-perl is available as the ubuntu package "libgo-perl"

I also had to: ...change the

I now found a not on my disktop that I also had to change the file /usr/bin/go2prolog like so:

go2fmt.pl -w prolog $@

-->
go2fmt -w prolog $@

You saved my day

I've been searching for clues why I'm getting null when I do get on Hashtable.
I was following this official tutorial about JPL.
http://www.swi-prolog.org/packages/jpl/java_api/getting_started.html
After checking your code, I found it.
You have to declare a Variable with a string.
And, do get with the initial string.

Thank you very much.

Hidenari