Gradle build cannot find symbol for Path.of()

Viewed 834

The project runs perfectly using Netbean's "build and run". However, due to the need to create a Fat Jar I had to add a gradle task CustomFatJar in build.gradle which looks like this:

    task customFatJar(type: Jar) {
    manifest {
        attributes 'Main-Class': 'com.Reject.Main'
    }
    baseName = 'all-in-one-jar'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
}

Thus, running the gradle like this using command prompt:

gradle customFatJar

and then get this result :

 error: cannot find symbol
 try (InputStream is = Files.newInputStream(Path.of(""), StandardOpenOption.READ)) {
                                                       ^
 symbol:   method of(java.lang.String)
 location: interface java.nio.file.Path

I believe I have imported Java nio file path in the main class:

 import java.nio.file.Path;

I could not find any clue how to fix this as the code runs completely fine in the IDE.

0 Answers
Related