Compile-time dependencies are not loaded

I am starting and I’ve tried to google that, but found nothing.
I am declaring dependencies at build.gradle

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.nanohttpd:nanohttpd:2.3.0'
    compile 'com.google.code.gson:gson:2.8.5'
}

but when i am trying to compile it with gradle/gradlew build/run i am getting list of errors ‘cannot find symbol’

/home/justicecurcian/Documents/cutoff-gui-server/src/name/justicecurcian/Server.java:18: error:cannot find symbol
Gson gson = new Gson();
    ^
symbol:   class Gson
location: class Server

what should i do here?