My friend and I are in a computer science class, and we were wondering how to edit the contents of a jar file? What software would we use, lines of code we might need, or any other input would be greatly appreciated. -From our computer to yours'- zach&kody

Recommended Answers

All 7 Replies

.jar files are just .zip files with some conventions about what's in them. A full description is on the Oracle java web site. You can edit them with your favourite zip file utility.

.jar files are just .zip files with some conventions about what's in them. A full description is on the Oracle java web site. You can edit them with your favourite zip file utility.

Doesn't unzipping just show the .class files though? I'm curious how you decompile a class file back into a java file

Yes. The class files and whatever other resources (images etc) the program uses.
If the program is intended for educational or demo purposes you may also find that the authour has included the source in the jar, but probably not.
You can find decompilers on the web, but don't expect too much. The decompiled code is going to be a lot harder to understand than the original, and original Java isn't always easy either without all the supporting documentation.
Without getting too heavy about the ethical/legal stuff... if the original author wants you to do anything with the source it will probably be available under some kind of open source licence and available on the web*. If the original author doesn't want you to have access to the source then (a) you're on dodgy ground trying to get it and (b) they are quite likely to have used obfuscation tools to make decompilation a waste of time.

* in particular - if you are interested in the source code for all the Java libraries (APIs) these are downloadable from Oracle's java web site.

I have opened the .jar file in Noptepad to find a large quantity of seemingly random symbols. I am using a computer at school, and without administrative rights, we cannot download anything. We do have jcreator, if that says anything, plus the java development kit. Any ideas of what we could use to make the random symbols, something we can translate?

Notepad won't help here because jar files are in a binary zip format. You must use a zip utility such as 7Zip, PKZip, WinZip, WinRar, Stuffit etc etc. Just search your machine for any .exe with "zip" in its name!
If there really isn't any zip utility on the machine, and you can't download, you can always fall back on the zip file support that's built into the Java API library and write (or copy) a Java "un-zipper"using the zip API. Eg this one:
http://www.java-tips.org/java-se-tips/java.util.zip/how-to-extract-file-files-from-a-zip-file-3.html

I am searching and have yet to find any file on my computer file with a "zip" in its name on my computer. I tried the link you left, and it says it cannot find my zipped file. The file I'm using is called "DanceStudio.jar" so I put DanceStudio in the spaces it askes for the zipped file, but the program cannot seem to find them, even when I made them a project and put them in the same folder. Any ideas? -From our computer to yours'- zach&kody

It looks like you're at a dead end here. You can't do this kind of thing without a least some of the right tools. All I can suggest is either find another project to do on your current PC or find another, less restricted, PC to work on.

commented: Thank you for your help +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.