Bonjour,

Afin de tester le programme java suivant
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import com.hp.hpl.jena.query.*;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.rdf.model.impl.LiteralImpl;
import com.hp.hpl.jena.sparql.util.IndentedWriter;
import com.hp.hpl.jena.vocabulary.*;
import com.hp.hpl.jena.util.FileManager;
 
public class premier {
 
        private static final String rdf = RDF.getURI();
        private static final String up = "http://purl.uniprot.org/core/";
 
        public static final String go_file = "O57539.rdf";
        public static final String NL = System.getProperty("line.separator") ;
 
 
    public static void main(String[] args)
       {
 
        Model m = ModelFactory.createDefaultModel();
 
            // use the file manager to load RDF descriptions into the model
        FileManager.get().readModel(m, go_file);
 
             // nombre de triplets du graphe genere
        System.out.println("nombre de triplets dans le modele O57539 : "+m.size());
             //Exploiter le graphe RDF
        // m.write(System.out);
 
        String prolog_up = "PREFIX uniprot: <"+up+">" ;
        // String prolog_rdf = "PREFIX rdf: <"+RDF.getURI()+">" ;
 
        // Query string.
        // String queryString = prolog_up + NL + prolog_rdf + NL +
        String queryString = prolog_up + NL +
        "SELECT ?sujet ?objet  "  
            + "WHERE {?sujet uniprot:mnemonic ?objet }" ;
 
        Query query = QueryFactory.create(queryString) ;
        // Print with line numbers
        query.serialize(new IndentedWriter(System.out,true)) ;
        System.out.println() ;
        // Create a single execution of this query, apply to a model
        // which is wrapped up as a Dataset
 
        QueryExecution qexec = QueryExecutionFactory.create(query, m) ;
        // Or QueryExecutionFactory.create(queryString, model) ;
 
        System.out.println("Essai sur les ressources qui possedent un mnemonic : ") ;
 
        try {
            // Assumption: it's a SELECT query.
            ResultSet rs = qexec.execSelect() ;
            // The order of results is undefined.
            for ( ; rs.hasNext() ; )
            {
                QuerySolution rb = rs.nextSolution() ;
                // Get title - variable names do not include the '?' (or '$')                
                System.out.print("Sujet "+rb.getResource("sujet").getLocalName());
                Literal rd = (Literal) rb.getLiteral("objet");
                System.out.println("Sujet "+rd.getLexicalForm()); 
 
 
            }
        }
        finally
        {
            // QueryExecution objects should be closed to free any system resources
            qexec.close() ;
        } 
       }
}
J'ai fait appel à la librairie de jena/lib en utilisant "java built path" et en intégrant les jars de Jena mais j'ai une erreur qui me dit :
"Description Resource Path Location Type
The method serialize(Syntax) in the type Query is not applicable for the arguments (IndentedWriter) premier.java /JENA_TEST/src line 42 Java Problem"
Si vous avez une solution, je vous serai reconnaissante.

Merci