Welcome to WebmasterWorld Guest from 3.80.4.76

Forum Moderators: travelin cat

Message Too Old, No Replies

How to view the source code for a Java applet?

I have Xcode, but it only shows some of the code

     
11:37 am on May 12, 2006 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Feb 12, 2003
posts:1208
votes: 0


A client has a Java applet on his website that I'd like to try to make some changes to. I download the file (filename.class), and drag it onto the Xcode application icon, and it opens up and shows some of the code, but not nearly all of it. The file is 20k but I'm seeing maybe 2k of code. It's just a bunch of function, class, object, and variable declarations -- there's no code that actually *does* anything. The last function is:

public void run() {
}

...and that's the last thing in the file. But where is the code for that function? There are no other files associated with this applet. It's very confusing.

1:31 pm on May 28, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 23, 2003
posts:801
votes: 0


There are lots of reasons why this might be.
The one that springs to mind is that something else extends this class, and *that* will be the class that implements the run method.

Usually it is possible to mark such as method as virtual, meaning that another class *must* implement it, but there are often occasions when the class itself can perform everything desired of it, and yet other classes may wish to inherit and specialise it by adding extra functionality.

Search for the class name in the other Java source files and you may well find a class extends it - that will have a run method with real code in it....

DerekH

8:12 pm on May 29, 2006 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Feb 12, 2003
posts:1208
votes: 0


I'm afraid I don't really understand any of what you're saying. But the point is, the one file I have, is the only file. I'm pretty sure there are no other files.
1:04 pm on May 30, 2006 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 1, 2003
posts:815
votes: 0


there's no code that actually *does* anything.

While I know next to nothing about Java, I've heard the quote above from colleagues who've tried to understand object-oriented code. If you're unfamiliar with object orientation, you might want to devote a few hours to learning the basics there.

What Derek is saying all sounds right. The file you are looking at probably does little besides "inherit" functionality from other classes, which may be in very different places on the hard drive's directory structure.

But we need a Java programmer to give specific advice...

10:53 pm on May 30, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 20, 2004
posts:1477
votes: 0


Where did the client get the applet to begin with? That might be a good place to start looking for the rest of the files.
6:46 am on May 31, 2006 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Feb 12, 2003
posts:1208
votes: 0


Like I keep saying, there *are* no other files. And as I said in my original post, the file is 20k but when I open with XCode I can see only about 2k of code.
1:26 pm on May 31, 2006 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 1, 2003
posts:815
votes: 0


the file is 20k but when I open with XCode I can see only about 2k of code.

Try opening it in a text editor like BBEdit, and let us know what you see.

3:34 am on June 1, 2006 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Feb 12, 2003
posts:1208
votes: 0


When I open with a text editor it's half gibberish (weird characters). I tried to post an excerpt but it doesn't display on WebmasterWorld when I click Preview. I could provide a link to the file except of course that's forbidden here.
2:29 pm on June 1, 2006 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 1, 2003
posts:815
votes: 0


It sounds like the unreadable stuff in the file is compiled code.

You may be able to get back to source code with a Java decompiler like Mocha:

[brouhaha.com ]
It's possible, however, that the original developer may have made it difficult to get back to the source code.

I'm wondering, is there a board at WW where we'd be likely to find more Java expertise?

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members