3
OWLDocumentFormat ontologyFormat = new RDFJsonLDDocumentFormat();
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.loadOntologyFromOntologyDocument(inputstream);
manager.saveOntology( ontology, ontologyFormat, outputstream );

In reference to the above code for 4th lines of code it is not accepting the saveOntology method and throwing this suggestion.Can you please help why is it doing so. You have used the same method in your code.

The method saveOntology(OWLOntology, OWLOntologyFormat, OutputStream) in the type OWLOntologyManager is not applicable for the arguments (OWLOntology, OWLDocumentFormat, OutputStream)

Ignazio
  • 10,504
  • 1
  • 14
  • 25
Shreshtha Garg
  • 165
  • 1
  • 2
  • 10
  • You're mixing up different versions of the OWL API, namely v3 vs v4 (or v5). `RDFJsonLDDocumentFormat` is version 4 or 5, but your code is using classes from version 3 – UninformedUser Mar 21 '18 at 06:44
  • The code compiles with version 5, and would compile with version 4. Version 3 is conflicting here - OWLOntologyManager is coming from version 3. – Ignazio Mar 23 '18 at 22:16

1 Answers1

4

This code compiles with version 4 and version 5:

import java.io.InputStream;
import java.io.OutputStream;

import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.formats.RDFJsonLDDocumentFormat;
import org.semanticweb.owlapi.model.OWLDocumentFormat;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyManager;

public class Check {
    public static void main(String[] args) throws Exception {
        InputStream inputstream=null;
        OutputStream outputstream=null;
        OWLDocumentFormat ontologyFormat = new RDFJsonLDDocumentFormat();
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        OWLOntology ontology = manager.loadOntologyFromOntologyDocument(inputstream);
        manager.saveOntology( ontology, ontologyFormat, outputstream );
    }
}

In your classpath you must have version 3 as well as version 4 or version 5, and the OWLOntologyManager interface declaration is coming from version 3. Make sure you only have one version in your classpath.

Ignazio
  • 10,504
  • 1
  • 14
  • 25
  • Thanks Ignazio for the answer. Yes i had two different maven dependencies with different versions in my pom file. Now i have only one with version 5. – Shreshtha Garg Mar 29 '18 at 11:34