I made a JAR file. That runs fine. I've been tinkering with the source and I forgot what changes were made. Now that is not working. Can I pull the .java from the Jar somehow?
-
Right click on the source file's tab and select _History_. – trashgod May 24 '15 at 10:15
-
IntelliJ offers it (https://blog.jetbrains.com/idea/2014/07/intellij-idea-14-eap-138-1029-is-out/). If you need to decompile a bunch of java classes, follow the discussion at https://stackoverflow.com/q/28389006/873282. – koppor Mar 15 '18 at 13:24
3 Answers
A JAR only contains .class files, which are compiled from .java source files. Unfortunately you can't edit the .class files and expect anything useful to come out of it.
This might work, though: JD GUI, a JAR decompiler.

- 875
- 2
- 12
- 19
-
This worked beautifully, albeit the compiler takes some liberties with some syntax so translating it back reflects said liberties as well. Thanks. – user3377627 May 25 '15 at 00:48
A jar file is similar to a zip file in that you can extract the contents. From the oracle website to extract from the command line (you can also use a program like 7zip):
The basic command to use for extracting the contents of a JAR file is:
jar xf jar-file [archived-file(s)]
Let's look at the options and arguments in this command:
The x option indicates that you want to extract files from the JAR archive.
The f options indicates that the JAR file from which files are to be extracted is specified on the command line, rather than through stdin.
The jar-file argument is the filename (or path and filename) of the JAR file from which to extract files.
archived-file(s) is an optional argument consisting of a space-separated list of the files to be extracted from the archive. If this argument is not present, the Jar tool will extract all the files in the archive.
NOTE: A jar file can contain any type of files and not just .class files.

- 3,454
- 2
- 36
- 65
extracting jar will give you just .class files. Still you can try java decompilers which can generate the source from .class files
results are not 100% guaranteed though

- 2,417
- 2
- 10
- 16