UnsupportedClassVersionError, Any suggestions?

Discussion in 'Spigot Plugin Development' started by ISellCowz, Jul 8, 2015.

  1. I keep getting the UnsupportedClassVersionError message, I've searched how to fix it and I have not found any ways that work.

    [07:25:21] [Server thread/ERROR]: Could not load 'plugins/TestPlugin.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: me/ISellCows/TestPlugin/Main : Unsupported major.minor version 52.0
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:291) [spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) [spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:528) [spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    at java.lang.Thread.run(Thread.java:745) [?:1.7.0_79]
    Caused by: java.lang.UnsupportedClassVersionError: me/ISellCows/TestPlugin/Main : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.7.0_79]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800) ~[?:1.7.0_79]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[?:1.7.0_79]
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) ~[?:1.7.0_79]
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71) ~[?:1.7.0_79]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[?:1.7.0_79]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[?:1.7.0_79]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_79]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[?:1.7.0_79]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425) ~[?:1.7.0_79]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ~[?:1.7.0_79]
    at java.lang.Class.forName0(Native Method) ~[?:1.7.0_79]
    at java.lang.Class.forName(Class.java:274) ~[?:1.7.0_79]
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    ... 6 more

    package me.ISellCows.TestPlugin;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;


    public class Main extends JavaPlugin implements Listener {

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    Player p = (Player) sender;


    if(cmd.getName().equalsIgnoreCase("test")){
    p.sendMessage(ChatColor.GREEN + "Test command");
    }

    return true;

    }

    @Override
    public void onEnable() {
    Bukkit.getPluginManager().registerEvents(this, this);
    Bukkit.getServer().getLogger().info("Enabled TestPlugin");
    }


    @Override
    public void onDisable() {
    Bukkit.getServer().getLogger().info("Disabled TestPlugin");
    }

    }

    name: GUIKits
    version: 0.1
    main: me.ISellCows.TestPlugin.Main
    author: ISellCows
    description: Test Plugin.
    commands:
    test:
    description: Test command

    Can anyone give me some suggestions to fix it?
     
  2. Change plugin or server java version.
    You have probably Server is on different Java version than Plugin.
     
  3. Would just installing Java 8 or Java 7 fix the problem?
     
  4. You must just start server on the same Java version as plugin.
     
  5. Are there any video tutorials or something you can give me the link to or can you give instructions on how to change the server java version/plugin java version?
     
  6. The plugin was compiled using Java 8. Either change the server to Java 8, or compile the plugin with whatever version your server runs on. A way to change the default jre of your server is to edit the Start.bat file. This is assuming, of course, that you have the appropriate jre installed.
    Code (Text):
    "C:\Program Files\Java\jre1.8.0_20\bin\java.exe" -Xmx1024M -jar spigot.jar -o true
    PAUSE
    You could simply follow that template. Change the path to wherever your java executable is stored.
     
  7. You can even change the version of Java when creating a project in the IDE.
     
  8. And how would you change the plugin version, can you send me a picture of where you change the java version while compiling?
     
  9. Well, do you compile it from the command line? or from an IDE? If you use an IDE, what is it?
     
  10. If you use Eclipse go to build path and in "Libraries" click on java version next click "Edit" and then select version of java you want.
     
  11. IDE, what I am confused
     
  12. I mean what IDE are you using?
     
  13. I did that, still get same error.
     
  14. I had the same error 1 year ago. :p
    You must create new project but while you are creating you must select java version not this in the build path.
     
  15. You need to change your Eclipse settings and then rebuild the project.
     
  16. Doesn't have to be the same. But the thing running the plugin must be the newer version. Java 8 can run Java 7 plugins, but not the other way round.
     
  17. Really? I always get the error when plugin java version isn't the same as server java version.
     
  18. That got rid of that error, now I have this error. Got any suggestions to fix it?
    [08:09:37 ERROR]: Could not load 'plugins/TestPlugin.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
    at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:154) ~[spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:291) [spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) [spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:528) [spigot-1.8.7.jar:git-Spigot-3ccbe77-a6a57a9]
    at java.lang.Thread.run(Thread.java:745) [?:1.7.0_79]
    Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
    ... 6 more
    It does have the plugin.yml, http://prntscr.com/7q8mwf
     
  19. Try compile one more time or delete and create again plugin.yml
     
  20. Did both, didn't fix.