# Need to guide about Virtual Graph via Java API

**URL:** <https://community.stardog.com/t/need-to-guide-about-virtual-graph-via-java-api/821>\
**Category:** Support\
**Created:** [February 22, 2018, 2:16am UTC](https://community.stardog.com/t/need-to-guide-about-virtual-graph-via-java-api/821 "2018-02-22T02:16:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mirae](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@mirae](https://community.stardog.com/u/mirae)\
**Post date:** [February 22, 2018, 2:16am UTC](https://community.stardog.com/t/need-to-guide-about-virtual-graph-via-java-api/821/1 "2018-02-22T02:16:06Z")

</div>

Hello.

I am trying to create virtual graph via java api.  
But I don't know how to do.  
I also check this link([Stardog-8.2.0 API](https://www.stardog.com/docs/java/snarl/com/complexible/stardog/virtual/api/admin/virtualgraphadminconnection)).

```java
try (final AdminConnection aConn = AdminConnectionConfiguration.toServer(url)
                .credentials(username, password)
                .connect()) {
            VirtualGraphAdminConnection vir = aConn.as(VirtualGraphAdminConnection.class);
            //How?
            //I want to change this command #stardog-admin virtual add --format r2rml test.properties test.ttl
            //vir.addGraph(....);
             aConn.close();
}

```

I also checked stardog-example.. But I can't find code or something about virtual graph api.  
Please help me. Thanks.

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [February 22, 2018, 2:21am UTC](https://community.stardog.com/t/need-to-guide-about-virtual-graph-via-java-api/821/2 "2018-02-22T02:21:59Z")

</div>

You are on the right track. The arguments to `addGraph()` are as follows:

- **name** - the name of the graph which would be `test` in your example command
- **properties** - a Java `Properties` object representing the connection and configuration of the virtual graph. You can use `Properties.load()` to load the contents of your file.
- **mappings** - a set of R2RML mappings in the form of a set of RDF triples. Perhaps you can use the `Rio.parse()` function here to read the contents of `test.ttl`. This will return a `Model` which will be accepted as an argument.

Hope this helps.  
Jess

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [March 8, 2018, 7:30am UTC](https://community.stardog.com/t/need-to-guide-about-virtual-graph-via-java-api/821/4 "2018-03-08T07:30:11Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
