Search code examples
javaintellij-idea

How to edit a .jar file in Intellij


I am working on a project in Intellij and i want o base it of an exisitng jar file. When i open it, everything shows up but i can't edit. Each time i try to make a change a window pops up saying File is read only. Can anyone help?enter image description here

I tried all sorts of things but no result, when i uncheck read only in properties, it just checks itself back enter image description here, i tried making it the content root, still nothing, i've looked at atleast 5 different articles, no luck.


Solution

  • First of all, you didn't give enough information, and like Robert's comment, it seems like an xy problem.

    .jar files are compiled java projects, they are basically .zip files made for the JVM, and they contain .class files, which is the file you are trying to edit, which are Java bytecodes. .class are not possible to modify in IntelliJ without plugins, as they are compiled files and not a source file.

    To be able to modify the existing .jar there are a few ways: Use a plugin or tool that allows modification of .class. Decompile the .jar using some tool.

    In other words, it is not possible to modify .class in IntelliJ without modifications to the IDE; either you would use a decompilation tool or you would modify your IDE with plugins.