11

I downloaded the code for a LAN messenger from sourceforge. It is an executable JAR file.
You double-click it and your messenger starts.

I want to study the source code. How do I do that?

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
A User
  • 375
  • 2
  • 4
  • 13

6 Answers6

18

Extract source code from .jar file

(1)Use JD GUI (http://jd.benow.ca/). Open the application, drag and drop your JAR file into it.

(2)You can extract a jar file with the command :

jar xf filename.jar

References : Oracle's JAR documentation

Community
  • 1
  • 1
Aruna
  • 189
  • 1
  • 3
2

Sourceforge has links to the source.

Naddiseo
  • 1,014
  • 1
  • 7
  • 17
2

Opening JAR files works with any software that supports the .ZIP file format, like WinRAR.

But if you want to access the source code, it gets a little tricky as in a JAR file, the Java code is already "precompiled" into Java's byte code. Fortunately, there is a (rough) way of decompiling byte code back to (usually) readable Java source code.

There are many programs that do this, my personal favorite is JAD (http://www.varaneckas.com/jad/).

Since you found the project on sourceforge, it is likely the code is not obfuscated. Although, if it is, you can still decompile it, but it is likely to be very hard to read and comprehend.

Kierrow
  • 685
  • 1
  • 7
  • 14
1

do you have eclipse in your computer?you can add the jar file to a project,then you can see the source code

andy Lau
  • 11
  • 1
0

IntelliJ is awesome at this type of thing. Just open like you would any other project, and it will decompile it for you.

Dave Mars
  • 3
  • 1
-1

Only two options available 1. Use decompiler tool like Cavaj or JAD. Source might be hard to make changes to. If it for understanding the funactionality it might help. 2. SourceForge should have link to source files too. I guess it is worth trying luck to check it again on SourceForge.

Mayank
  • 796
  • 1
  • 10
  • 12