Import Error in JAVA API


#1

Hi Community,

I am trying to use JAVA API using Eclipse as IDE and as per the documentation the first line
import ai.grakn.graql.QueryBuilder itself creates the exception ‘Unresolved import’ in the IDE…

I am referring from here:
https://grakn.ai/pages/documentation/developing-with-java/java-graql.html#querybuilder

I wonder what i am doing wrong…

Please suggest…


#2

Hi @Xnsam,

Have you created a maven project and add the following to your dependencies:

<dependency>
    <groupId>ai.grakn</groupId>
  <artifactId>grakn-graql</artifactId>
  <version>${project.version}</version>
</dependency>
``` 

The instructions assume that you are using maven for your dependency management.

#3

Hi @filipe,

Thank you for the prompt response…To be frank i am not well-versed with maven…please can you guide with the instructions of doing so?..
I have edited the pom as mentioned in the docs…though…


#4

Right, so the first step is to make your java project a maven one. There are already many well written articles on how to do so. Here is one that will guide you step by step in setting up maven in eclipse.

Once you get to the part of setting up pom.xml all you have to do is copy the following into the pom:

<dependencies>
<dependency>
<groupId>ai.grakn</groupId>
<artifactId>grakn-graql</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

and that should resolve your issues.


#5

Hi @filipe,

Thank you for the prompt reply…yes will try out as per your instructions…