Minecraft and Java 1.7

Discussion in 'Plugin Development' started by bastion, Aug 25, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    bastion

    I recently came across an issue regarding craftbukkit and java 1.7.

    Some plugins are not compatible with java 1.7 but most other plugins are compatible. What is the expected current working environment for craftbukkit and java?

    A plugin dev actually stated that minecraft does not work with java 1.7, is this true and if so why was I able to run craftbukkit 1.2.5 with all the plugins on java 1.7 but have issues with craftbukkit 1.3.1 r2 running some plugins on java 1.7?

    I am rather confused and could use some help in understanding this issue.
     
  2. Offline

    Giant

    Minecraft seems to work just fine on Java 1.7 for me. Java should also be most downward compatible, so I suppose the few plugins that do break are using things in Java that did get changed and now result in a different outcome.

    I know Bukkit still requires their Pull Request to be Java 1.5 compatible though. According to the readme's anyways...
     
  3. Offline

    Courier

    Yeah... I run JRE1.7 and have never had any problems. In fact, most of my plugins are compiled for 1.7 because I use some of its features. JRE is mostly backwards compatible.
     
  4. Nobody said Minecraft didn't work with Java 1.7... you misinterpreted.
    Minecraft and CraftBukkit are both compiled on Java 5 to support any version starting from 5.
    Most plugins are compiled on Java 6, therefore they work on Java 6, 7 and later.
    Some plugin devs are unware that compiling plugins on Java 7 will prevent them from workong on servers that run on Java 6 (the same if you compile on Java 6 and run on Java 5).

    Now... as a server, if you want to use all possible plugins, use the latest Java, Java 7, it's that easy.

    You're stuck on the whole Java version thing which is probably NOT the reason why the plugins don't work, the most probable situation is that they're using outdated methods or class that don't exist in 1.3.1 R2... or they use them inproperly and now they trigger errors in the new CB...

    The error which states that your Java version is incompatible with the Java version the plugin was built on is "Unsupported major.minor version ...".
     
    CorrieKay likes this.
  5. Offline

    bastion

    Code:
    This is the quote from the dev of serversigns:
     
    Minecraft runs with Java 1.6 only, if I compile the plugins with java 1.7 it wouldn't even load.
    I am not sure how I would misinterpret this quote. However I do see how the distinction between compiling a plugin for 1.6 v 1.7 may cause problems if you are running 1.6. So if the plugin is compiled with 1.7 it will more than likely not work with 1.6.

    However you did answer my question, if using java 7, plugins compiled with java 5 or 6 "should" work.

    I am actually not "stuck" on anything. If a plugin works with java 7 on cb1.2.5r5 but then will only operate partially on java 7 with cb1.3.1.r1 or r2, what I take from your statement is the dev is not using some kind of format or class or method properly, or one of his methods or classes is not compatible with cb1.3.1. However, if that same plugin works fully with java 6 on cb1.3.1r2, this logically does not make sense.

    So we come back to java 7 should be backwards compatible, but running java 7 with cb1.3.1 may cause some plugins to not operate properly. It is not that java is incompatible, it is more the changes made are causing some kind of error in the plugin. This is what I was looking for.
     
  6. Offline

    Courier

    That is wrong. Minecraft does not run Java; Java runs Minecraft. If you run Minecraft in JRE1.7, it will be running in Java 1.7. Many servers run JRE1.6, but Java 1.7 has been out for over a year and ports exist for every OS I've used. Java is (supposedly) backwards compatible. The quote from that dev is wrong. He means that if he compiles his plugin for Java 1.7, it won't run on a server that is 1.6 or below.
     
    bastion likes this.
  7. Offline

    bastion

    Cool, got the compile thing, plugins should be compiled in 1.6 mainly to accommodate all the servers that have not updated to java 1.7 and I am sure there are a lot of servers out there not running 1.7.

    Now how can I possibly explain to the dev, that although his plugin works fine with cb1.3.1r2 and java 1.6, it does not operate fully with cb1.3.1r2 and java 1.7? Part of the plugin works, using the plugin works, but trying to create or edit does not work with 1.7?
     
  8. Offline

    Courier

    I suppose you should let him know, and direct him here. Let him know if you are getting any errors, and which features are not working in Java 1.7 which are in the same version of CraftBukkit under Java 1.6. Also let him know exactly which versions of the JRE you are using (type "java -version" in a command prompt) and if it is from Oracle or OpenJDK.
     
    bastion likes this.
  9. Offline

    bastion

    Thank you, I appreciate your time and will follow up with the dev.
     
  10. Courier likes this.
  11. Offline

    Courier

  12. Offline

    bastion

    They have different versions available, oracle version is at u6 and openjdk is at u3 and there is an oracle dev build for u8.
     
  13. AFAIK (can have been changed) around 5% of Oracle JDK and OpenJDK differ (parts like font rendering). Hopefully Oracle will (if not already happened) either open source the remaining parts or use the ones from OpenJDK. It's annoying to have two different versions of the same software. :/

    But the point that OpenJDK is the reference implementation is still valid.

    //EDIT:
    Hopefully Oracle has more releases cause they slowly kill the proprietary parts. ^^
     
  14. Hey, I am the dev of serversigns, the plugin causing problems on 1.7 Servers.

    The error occurs at a Player interact event. I'll paste the lines in here, maybe you can help me with the problem because I can't find anything that could be wrong.


    Code:
    Block block = event.getClickedBlock(); //line 44
    Location location = block.getLocation(); //line 45
    

    The exception is the following:
    Code:
    Caused by: java.lang.NullPointerException
        at de.craftville.ServerSigns.Listeners.PlayerListener.adminInteractCheck(PlayerListener.java:45)
    I'll try the plugin with 1.7 again and do some debug, but feel free to post solutions here.



    You are right, I mixed something up. I compiled a .class file for craftbukkit (to fix TNT "bug") with 1.7 which results in not loading the server, sorry.
     
  15. CalibeR.50 But you are checking that it's a click on a block before that (I know, stupid question but with that small code snippet I have to ask to get sure).
     
  16. CalibeR.50
    I had a look at your code, you're not aware that event.getClickedBlock() returns null if player doesn't left/right click a block and you're using a method on it (.getLocation()) without checking if it's null or not.

    You can just check if block == null and return... or check event.hasBlock() which does the same null check or compare if event.getAction() equals either Action.RIGHT_CLICK_BLOCK or Action.LEFT_CLICK_BLOCK.


    V10lator
    Not a stupid question, expecially when the Java version is blamed for the reason of a NPE xD
     
    V10lator likes this.
  17. Hm no, but until Minecraft 1.3 it worked without problems and without errors... Let me make some debug, but I don't think this is the problem.

    I fixed another error, but it has nothing to do with the NullPointerException.

    I don't know why I should check whether the block is null or not because you can't interact with anything else. I can click the air and even a villager and don't get this error (with java 1.7 and craftbukkit 1.3.1 R2). I really don't know what cause this exception.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  18. @CalibeR.50 Or nobody noticed the errors. If you aren't checking the expected output is to give errors. Read what Digi wrote.

    //EDIT: And of course you can interact with air. Some plugins check for this...

    //EDIT²: Now instead of searching endless for another error add in a if(event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) return; and check if it fixes your problem...
     
  19. CalibeR.50
    Try to understand what we're telling you if you want to avoid the NPE.

    But the point is that Java version has nothing to do with your error, so please stop telling that to people, it's your code's fault wether you want to accept that or not.
     
    Sagacious_Zed likes this.
  20. Offline

    bastion

    @CalibeR.50

    is not trying to dodge the issue, we thought it might be the java version, we have found out different. Cal is trying to solve the issue, there is no reason to get snarky, he is no longer saying it was a java issue.
     
  21. The problem is, I don't get this error on my server(s). I tested everything, clicked anything, tried anything, but it is working without problems. I need to get this error on my servers to fix this (or I never can really be sure it is working after a fix)
    If an admin want to use the plugin he has to type in a command. After that the plugins checks for interactions with anything. The users telling me that the plugin don't work and post this error, but if this is true, they right click the block (no need to check for right click block action, because it would be true) and don't do anything else. If I insert a check if they right click a block or if the block exists the plugin still won't work, it just wouldn't print an error.

    I don't tell people that it is the java version, bastion was the first who tried it out and noticed that it is working with 1.6

    Air is a block, too. So my plugin wouldn't throw a NPE....
     
  22. bastion
    Well, he's ignoring our advice, that's for sure :)

    CalibeR.50
    You didn't test properly, just randomly clicking won't do because you have a check there that only allows the event to trigger if you're doing a command...
    Also, PlayerInteractEvent doesn't trigger for all held items, for example it doesn't trigger if you rightclick air with empty hand.
    I've tested myself, "/svs add test" and left clicked air... I've tested on both java 6 and 7 !
    NullPointerException (open)
    Code:
    23:24:34 [SEVERE] Could not pass event PlayerInteractEvent to ServerSigns
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:332)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462)
            at org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:177)
            at org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:147)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:920)
            at net.minecraft.server.Packet18ArmAnimation.handle(SourceFile:41)
            at net.minecraft.server.NetworkManager.b(NetworkManager.java:276)
            at net.minecraft.server.NetServerHandler.d(NetServerHandler.java:109)
            at net.minecraft.server.ServerConnection.b(SourceFile:35)
            at net.minecraft.server.DedicatedServerConnection.b(SourceFile:30)
            at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:581)
            at net.minecraft.server.DedicatedServer.q(DedicatedServer.java:212)
            at net.minecraft.server.MinecraftServer.p(MinecraftServer.java:474)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:406)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:539)
    Caused by: java.lang.NullPointerException
            at de.craftville.ServerSigns.Listeners.PlayerListener.adminInteractCheck(PlayerListener.java:45)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:330)
            ... 16 more
    

    So can you just add a check at the begining of the event and be done with it ? :)
    Code:
    if(event.getAction() != Action.LEFT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_BLOCK)
        return;
    EDIT
    Now it is I who can say "That's what I've keep telling him.", V10lator can also say that xD
     
  23. Offline

    Giant

    CalibeR.50 also whilst "AIR" is a block, it does not get returned as a block when you click on it... It would actually return "null".

    Edit:
    I know Digi, but I suppose some users are quite stubborn aren't they? :D
     
  24. So you have two errors: First the missing check which is the cause of the NPE and second another one which is completely unrelated to the first. Fixing the first is still a good idea, then you should search for the second.
     
  25. Ok, you are right. The error occurs if you left click the air. But the plugin is working for me, fixing the error won't make the plugin work for these who say it isn't working (I'll fix it even so).

    @bastion: Are you sure that the plugin wasn't working at all? Or did you just see this error?
     
  26. Offline

    bastion

    As i have said before, a player with the .use permission can right click a sign and it seems to work. The error occurs when you try to do any of the admin or create commands, so add, edit, list etc, if all you do is right click the sign it seems to work.

    so if you try to create a new sign or edit one it does not work.
     
  27. But this is the only error? Because this error is just not nice too see, but it don't make the plugin not working.


    edit: I will upload a fixed one, would be great if you can test if it works for you
     
  28. Offline

    bastion

    ok, so one of the other guys on the plugin thread has found that the error may be being caused by the interaction of svs and vault. He did not state which vault but i also use vault, i am currently using vault 1.2.18, and it is a dependency for other plugins I use.
     
Thread Status:
Not open for further replies.

Share This Page