Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8081737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:49:59+00:00 2026-06-05T16:49:59+00:00

How can I list all Object Properties associated to a instance in Jena? For

  • 0

How can I list all Object Properties associated to a instance in Jena?

For example:
A Person has an Object Property called “hasVehicle” which is associated with a class Vehicle

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:50:01+00:00Added an answer on June 5, 2026 at 4:50 pm

    The appropriate Jena method is OntClass.listDeclaredProperties. There are some nuances to be aware of; the Jena RDF frames how-to explains in detail.

    Update

    OK, I’ve looked at your code sample, and read your description, and I’m afraid I don’t understand what you want to do. What I’ve done is re-write your code sample so that it does something that I guess you might want, based on your description in the comment:

    package test;
    
    import com.hp.hpl.jena.ontology.*;
    import com.hp.hpl.jena.rdf.model.*;
    import com.hp.hpl.jena.util.FileManager;
    import com.hp.hpl.jena.util.iterator.ExtendedIterator;
    
    public class LeandroTest
    {
        public static String NS = "http://www.owl-ontologies.com/TestProject.owl#";
    
        public static void main( String[] args ) {
            OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM, null );
            FileManager.get().readModel( m, "./src/main/resources/project-test.owl" );
    
            OntClass equipe = m.getOntClass( NS + "Equipe" );
            OntProperty nome = m.getOntProperty( NS + "nome" );
    
            for (ExtendedIterator<? extends OntResource> instances = equipe.listInstances(); instances.hasNext(); ) {
                OntResource equipeInstance = instances.next();
                System.out.println( "Equipe instance: " + equipeInstance.getProperty( nome ).getString() );
    
                // find out the resources that link to the instance
                for (StmtIterator stmts = m.listStatements( null, null, equipeInstance ); stmts.hasNext(); ) {
                    Individual ind = stmts.next().getSubject().as( Individual.class );
    
                    // show the properties of this individual
                    System.out.println( "  " + ind.getURI() );
                    for (StmtIterator j = ind.listProperties(); j.hasNext(); ) {
                        Statement s = j.next();
                        System.out.print( "    " + s.getPredicate().getLocalName() + " -> " );
    
                        if (s.getObject().isLiteral()) {
                            System.out.println( s.getLiteral().getLexicalForm() );
                        }
                        else {
                            System.out.println( s.getObject() );
                        }
                    }
                }
            }
        }
    }
    

    This gives the following output, by first listing all resources of rdf:type #Equipe, then for each of those it lists the resources in the model that link to that Equipe, then for of those linked resources it lists all of the RDF the properties. I don’t think that’s a particularly useful thing to do, but hopefully it will show you some patterns for traversing RDF graphs in Jena.

    Equipe instance: Erica
    Equipe instance: Etiene
      http://www.owl-ontologies.com/TestProject.owl#EtapaExecucao_01
        EtapaExecucao_DataModificao -> 2010-03-29T10:54:05
        caso_de_teste -> http://www.owl-ontologies.com/TestProject.owl#CasoDeTeste_01
        EtapaExecucao_StatusTeste -> Passou
        EtapaExecucao_Reprodutibilidade -> Sempre
        type -> http://www.owl-ontologies.com/TestProject.owl#EtapaExecucao
        EtapaExecucao_VersaoDefeitoSurgiu -> Release ICAMMH_01.00
        EtapaExecucao_Severidade -> Minimo
        EtapaExecucao_VersaoDefeitoCorrigiu -> Release ICAMMH_02.00
        DataExecucao -> 2009-07-10T09:42:02
        EtapaExecucao_StatusDoDefeito -> Nao sera corrigido
        EtapaExecucao_DataSubmissao -> 2009-06-30T09:43:01
        Tipos_Fases -> http://www.owl-ontologies.com/TestProject.owl#FaseTesteExecucao
        EtapaExecucao_Resolucao -> Fechado
        executor_do_teste -> http://www.owl-ontologies.com/TestProject.owl#Etiene
        EtapaExecucao_PrioridadeCorrecao -> Normal
    Equipe instance: Fabio
    Equipe instance: Melis
    

    Some general suggestions, particularly if you have any follow-up questions:

    • ask specific questions, it’s very hard to answer a vague unclear question;
    • provide runnable code if possible: you can take my code below, drop it into a code environment like Eclipse and try it out
    • provide the code and data in the question, not linked off on pastebin
    • take some time to reduce the code and data to the minimum form necessary to show the problem: your Protégé file was over 600 lines long
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to list all filenames which is having alien.digits digits can be anytime
Following this example, I can list all elements into a pdf file import pyPdf
How can I list all instantiated objects in all application, using FASTMM4 or default
SELECT name FROM sys.databases -- this can list all database name in the server
How can I list all the classes in my current project(assembly?) using reflection? thanks.
I have an app from where I can get the list of all installed
How can i get a list of all changes from TFS that were in
How can I to get list of all wcf services running on a machine?
How can I get a list of all the MySQL databases that exist on
How can I get a list of all the selected values ​​for a field?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.