satoshinm / WebSandboxMC

Bukkit plugin providing a web-based interface with an interactive WebGL 3D preview or glimpse of your server 🕷⏳📦 ⛺
https://www.spigotmc.org/resources/websandboxmc.39415/
MIT License
19 stars 5 forks source link

Error:(57, 38) java: The type java.util.function.Function cannot be resolved. It is indirectly referenced from required .class files #90

Closed satoshinm closed 7 years ago

satoshinm commented 7 years ago

When I compile in IntelliJ IDEA, but not from Maven on the command-line, there is a compile error on the code added for https://github.com/satoshinm/WebSandboxMC/issues/51 Sponge support:

            this.unbreakableBlocks = rootNode.getNode("nc", "unbreakable_blocks").getList(TypeToken.of(String.class));
satoshinm commented 7 years ago

https://stackoverflow.com/questions/5547162/eclipse-error-indirectly-referenced-from-required-class-files says "You should make sure to add the required jar to the classpath."


Preferences, Build, Execution, Development, Build Tools, Maven, Maven home directory was set to built-in Maven 3 "(Version 3.3.9"). Changed to /Users/admin/.m2, which is detected as version 3.5.0. But no difference.


Compiler > Java Compiler, had set to Eclipse. Changed to javac and am now able to compile no errors.

Husky2490 commented 6 years ago

For those who come across this page from Google, this is caused by Java 1.7 being specified as the target version in pom.xml.

I encountered the same problem while attempting to compile the latest version of Spigot in IntelliJ using JDK 10.0.1 and javac for my compiler within the spigot-api module. After trying the above, I searched some more and decided to take a closer look at the target bytecode version numbers I had glanced over while checking which compiler I was using.

Module Target bytecode version
spigot 1.8
spigot-api 1.7
spigot-parent 1.5

I then looked to see when java.util.function.Function was added and that was 1.8.

Two solutions to this: update the target bytecode version to 1.8 or newer OR disable use of module-specific JDKs

Husky2490 commented 6 years ago
<properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>