Java decompile - How to download applets and decompile Java class files - Part 1


This article is a little old now, so I've started a new series (as of April, 2010) on Java obfuscators and decompilers. Please follow that link for much more recent information. The content below is still valid, but mostly kept because it discusses how to download Java applets.


Before starting, I must admit that for a long while I treated this topic by burying my head in the sand. The thought that people around the world could decompile my Java applets and applications was something I didn't think about, or didn't want to think about. But then one day, as the Biscuit on the television show Ally McBeal might say, I became "troubled".

I'd like to say that decompiling Java applets is hard. The fact is that there's nothing magical, mystical, or even difficult about decompiling Java classes. In this series of articles you can learn the exact steps needed to download Java class files, and then decompile the Java class code - turning the Java binary code back into the original source code.

Why write this Java article?

We decided to create this article for two reasons:

  1. First, we're a Java educational center. Telling you the bad things about Java as well as the good is also educational. Whether it's bad or good, it is truth, and people can do this.
  2. Second, and more importantly, if you know how to decompile Java classes you can also learn how to try stop it (if you're interested in stopping it).

How to download a Java class file from an applet

If you see an applet that you like, downloading the class file(s) for that applet is generally pretty easy. Here are the steps:

The step-by-step process

  1. First, when you see an applet that you like, make sure you're looking at that applet in your browser (Netscape or Internet Explorer).
  2. With the applet in your browser window, click on View | Page Source (Netscape 4.x), or View | Document Source (Netscape 3.x), or View | Source (IE 3.x) from the pull-down menu in your browser. I don't have a copy of IE 4.x with me at this time, but I think you get the idea.
  3. Next, search for the text string "<applet" or "<APPLET" in the source code for that page. The idea is to find the beginning of the <APPLET ...> tag in the HTML source. This tag will tell you where the Java class file is located.
  4. When you find the applet tag, look for the name of the class file being invoked for the the applet. The tag will usually look like this: <APPLET CODE="MyApplet.class" WIDTH=350 HEIGHT=200></APPLET>
  5. This tells you that the binary file MyApplet.class is located in the same directory as the HTML file. Downloading the class file is very simple. Go back to your browser, and replace the name of the HTML file you're viewing with the name of the class file in the field where you'd normally type the URL.
  6. Hit the <Enter> key. Each browser behaves a little differently, but in general they'll prompt you to ask where you'd like to download the file to on your local filesystem. Store the class file wherever you'd like. (Note: If the browser tries to rename the file with a different filename extension like ".exe", just change the extension to ".class" before saving it.)

A step-by-step example

That's all you have to do. Does it seem too easy? Try it on our site. Here's how to download the class file for our popular AnimatedAd applet.

  1. Point your browser to "".
  2. Assuming you're using Netscape 4.x, click on View | Page Source.
  3. Search for the text string "<applet" or "<APPLET" in the source code for that page by hitting <Ctrl>F in the viewing window, then entering the string. You'll find that the applet tag shows that the AnimatedAd.class file is in the same directory as the HTML file. There are no directory paths preceding the string "AnimatedAd.class".
  4. Close you're viewing window and go back to your browser. In the browser's Location: field, replace the name AnimatedAd.shtml with the name AnimatedAd.class. The URL should now be "".
  5. Hit the <Enter> key. Netscape prompts you by asking where you'd like to save the file. Save it wherever you'd like, or cancel the process. Remember to rename the extension to ".class" if Netscape changes it to ".exe".

The process can get a little more complicated if the applet author uses a "CODEBASE" parameter with the <APPLET> tag, but this only means that they've stored the applet in a different directory. Just include any directory information you see in the URL tag when you replace the .html filename with the .class filename.

The process also gets more complicated if the author uses more than one class file to create their applet. For instance, our AnimatedAd applet requires a helper class named GetAppletParameter.class. Unfortunately, you won't know this until you decompile the AnimatedAd.class file.

What's next

In our next article, we'll show you how to decompile the Java class file after you've downloaded it to your computer system. Decompiling the code turns the Java class file (a binary file) into a Java source code file, meaning you can look at the source code an author used to generate their applet or application.

(Editor's Note: The process of decompiling Java class files belonging to other businesses or individuals may be illegal in your city, state, or country. Frankly, I don't know for sure, because, to coin a phrase from Star Trek's (TM) Doctor McCoy, "I'm an editor, not a lawyer." In any case, this series of articles is not written to encourage that practice. These articles are presented only so you can learn to protect your own Java class files from reverse engineering.)


Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.