Solved Java version mismatch?

Discussion in 'Spigot Plugin Development' started by TutForMinecraft, May 27, 2016.

  1. Hello, I am trying to make a custom plugin for my small server. I am having this error in my console... It is a hosted server if that makes a difference. Also I have compiled with Java 6, Java 7, and Java 8 all with the same error.

    Code (Text):
    26.05 23:55:01 [Server] ERROR Could not load 'plugins/DeathChest.jar' in folder 'plugins'
    26.05 23:55:01 [Server] INFO org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: me/robert/dc/DeathChest : Unsupported major.minor version 52.0
    26.05 23:55:01 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[craftbukkit_1.9.4.jar:git-Bukkit-c5e9a16]
    26.05 23:55:01 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:328) ~[craftbukkit_1.9.4.jar:git-Bukkit-c5e9a16]
    26.05 23:55:01 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [craftbukkit_1.9.4.jar:git-Bukkit-c5e9a16]
    26.05 23:55:01 [Server] INFO at org.bukkit.craftbukkit.v1_9_R2.CraftServer.loadPlugins(CraftServer.java:293) [craftbukkit_1.9.4.jar:git-Bukkit-c5e9a16]
    26.05 23:55:01 [Server] INFO at org.bukkit.craftbukkit.v1_9_R2.CraftServer.<init>(CraftServer.java:255) [craftbukkit_1.9.4.jar:git-Bukkit-c5e9a16]
    26.05 23:55:01 [Server] INFO at net.minecraft.server.v1_9_R2.PlayerList.<init>(PlayerList.java:70) [craftbukkit_1.9.4.jar:git-Bukkit-c5e9a16]
    26.05 23:55:01 [Server] INFO at net.minecraft.server.v1_9_R2.DedicatedPlayerList.<init>(SourceFile:14) [craftbukkit_1.9.4.jar:git-Bukkit-c5e9a16]
    26.05 23:55:01 [Server] INFO at net.minecraft.server.v1_9_R2.DedicatedServer.init(DedicatedServer.java:181) [craftbukkit_1.9.4.jar:git-Bukkit-c5e9a16]
    26.05 23:55:01 [Server] INFO at net.minecraft.server.v1_9_R2.MinecraftServer.run(MinecraftServer.java:510) [craftbukkit_1.9.4.jar:git-Bukkit-c5e9a16]
    26.05 23:55:01 [Server] INFO at java.lang.Thread.run(Unknown Source) [?:1.7.0_51]
    26.05 23:55:01 [Server] INFO Caused by: java.lang.UnsupportedClassVersionError: me/robert/dc/DeathChest : Unsupported major.minor version 52.0
    26.05 23:55:01 [Server] INFO at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.7.0_51]
    26.05 23:55:01 [Server] INFO at java.lang.ClassLoader.defineClass(Unknown Source) ~[?:1.7.0_51]
    26.05 23:55:01 [Server] INFO at java.security.SecureClassLoader.defineClass(Unknown Source) ~[?:1.7.0_51]
    26.05 23:55:01 [Server] INFO at java.net.URLClassLoader.defineClass(Unknown Source) ~[?:1.7.0_51]
    26.05 23:55:01 [Server] INFO at java.net.URLClassLoader.access$100(Unknown Source) ~[?:1.7.0_51]
    26.05 23:55:01 [Server] INFO at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.7.0_51]
    26.05 23:55:01 [Server] INFO at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.7.0_51]
    26.05 23:55:01 [Server] INFO at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_51]
    26.05 23:55:01 [Server] INFO at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.7.0_51]
    26.05 23:55:01 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:77) ~[craftbukkit_1.9.4.jar:git-Bukkit-c5e9a16]
     
  2. What java version does the server have? What are you compiling with, have you properly set up the JDK in your compiler?
     
  3. You must run and compile your application with the same version of Java.


    Make sure the Java version you are using to compile the project is the same as the Java version you are using to execute the plugin within the server. You most likely did not setup the JDK correctly within your Java IDE.
     
  4. the server can have a newer version, so the way it works is JavaCompiled<=JavaServer or else it will throw this error. also like you said it could be a badly configured IDE
     


  5. Update your server's Java.
     
  6. If your java version on the server and your java version in your IDE when compiling are the same, you will never run into this issue.
     
  7. You need to compile against a lower or an equal version of Java than the one the server is running
     
  8. No need to keep providing the solution multiple times.
     
    • Agree Agree x 1
  9. MajMinor 52.0 == Java 8, you're using 7.
     
  10. Why won't these damn people google D;
     
  11. Note: Java 7 is compatible with both (obviously) itself and Java 8.
     
    • Agree Agree x 1
  12. Previous answers (including yours) implied it had to be compiled and run with the same version of Java. It doesn't.
     
    • Agree Agree x 1
  13. Thanks for all of the answers, I know it had to be compiled with the same or lower my issue was not knowing what version the server used and the host wasn't answer so I thought maybe the error would say I just didn't know how to read it.

    I guess I should add my problem was my eclipse project had its own setting for the compiling using Java 8, even though I had my default compiler as Java 7.

    To solve this I had to right click on the project > Properties > Java Compiler > Compiler Compliance Level <- Set this to what ever the server is using.
     
    #13 TutForMinecraft, May 27, 2016
    Last edited: May 27, 2016
    • Informative Informative x 1