How to import class from local jar

Hello. I have created a custom .jar and I have included it in the build.gradle file as follows

dependencies {
compile files ("./external_jars/NameOfJar.jar")

Unfortunately, I don’t know how to import the class from this JAR in another java code… Could you please help me?

If your build.gradle file declares the dependency as shown, that jar will be available on the compile classpath when Gradle compiles your project Java code. There is nothing special that needs to done having declared the dependency in Gradle.

Inside your your jar, there should be a folder structure with your class files like:


Therefore, the consuming Java file should contain:

import name.of.package.NameOfClass;