how can i edit a .jar file

Discussion in 'Spigot Plugin Development' started by Cads181mc, Jun 1, 2017.

  1. hello i need to edit a .jar file can eny one point me in the direction of a program or a website

    cads181
     
  2. what do you mean
     
  3. Mas

    Mas

    What don't you understand?
     
  4. Please rephrase your question to clarify if you wish to customize an existing plugin (if the license permits this) or if you wish to create your own plugins (learn how to code)
     
  5. I don't think he realizes that .jar files cannot be easily edited. It's not like you can stuff them in Notepad++ and expect to see the source code.
     
    • Agree Agree x 1
  6. I already pretty much explained it to him...
     
  7. Use a decompiler to decompile the code
    Make changes
    Compile the code and put it in a jar

    There is one problem... compilers do some weird optimalization that a decompiler doesn't know about. Best is to ask for the source code as @ExpDev said
     
  8. If it dont contains the source code you must decompile it. I use jd-gui for it. Then you must do it in an IDE and Built it again. And i know my English is terible.
     
    • Funny Funny x 2
  9. there are many websiteds that can get the java files for you. java is "encrypting" the files and making them hard to read but you can pop the jar file in on this website: http://www.javadecompilers.com and get the files of the actual coding and to get the configs download winrar and open as an archive and you will se it there. pop it in eclipse and there you go.
     
  10. Wait... it is not encrypting them but compiling them!?!? Or am i wrong? That is why some code gets messed up after decompilation: the original code is lost.
     
    • Agree Agree x 1
  11. Its really hard to decompile java-bytecode and get it working afterwards. If you only want to make little change to the programm you could edit the .class files in the .jar with an hex-editor. But it takes time to find the right thi gs to change in bytecode.
     
    • Funny Funny x 1
    • Optimistic Optimistic x 1
  12. thats why i did this "encrypt" since its not what it excactly means but close enough for an explaination
     
  13. i must disagree about that i have deompiled at least 100 plugins without any problems
     
  14. But at encryption you keep 100% of your information. It is lossless. When compiling you lose your code and it gets changed to machine code type of stuff that is not real machine code.

    It is not something that is common, but it can happen. I have had problems when i tried decompiling the spigot jar to make my own version of a server software.
     
  15. A good decompiler can reconstruct the code to a certain degree. I wouldn't recommend to use JD-GUI, it's known to be a bad decompiler. Use something like Krakatau, CRF, Fernflower or Procyon (advertisement: they're all provided by Helios)
     
    • Agree Agree x 1
  16. Okay i didn't decompile any plugins yet but when decompiling bigger projects i spent loads of time fixing all the errors the decompiler created.
     
  17. then you probably used the wrong type of bukkit/spigot or used a bad decompiler
     
  18. Well i didnt find any perfect decompiler yet
    And I dont think every programm can be decompiled without any errors even with the best decompiler you could possibly find
     
  19. Exactly, one reason for that is the fact that the JVM allows return type method overloads, while java doesn't. Therefore perfectly valid bytecode could result in invalid java code when decompiled.