View Full Version : Java

Immortal Wombat
02-05-2003, 18:10:07
This month's language of choice is Java. :bounce:

I'm not attempting to learn it just yet, but is there any way to deconstruct and reconstruct java classes with changes?

A friend of mine made an applet, and I can't figure out how to decompile, alter and then recompile the class file. I've downloaded a whole load of crap from the SunMS website, and a thingummy called DJ Java Decompiler, which lets me read the classes as plain text.


02-05-2003, 18:14:54
As plain text as in source code, or as plain text as in bytecode?

Immortal Wombat
02-05-2003, 18:21:36
Bytecode I think.

What's the difference?

02-05-2003, 18:28:15
IANACSS (Computer Science Student): bytecode is compiled for the environment, e.g. a .pyc file. Source code is human-readable (unless it’s, like, K or something), e.g. a .py file.

Immortal Wombat
02-05-2003, 18:31:02
oooooh. sourcecode.

02-05-2003, 18:33:28
Well then, what is the problem?

Immortal Wombat
02-05-2003, 18:37:55
Compiling it.

02-05-2003, 18:45:21
:bash: doh.

http://gcc.gnu.org/java/compile.html perhaps?

Immortal Wombat
02-05-2003, 20:00:13
aargh! :bash: I hate that site. It provides a whole load of sodding files that do nothing at all, a whole load of documention which is only useful if you either wrote the stuff or have been doing it for a gazillion years already.

Look at the "FAQ":
Q1: What is the relationship between GCC and EGCS?

That is a frequently asked question? My arse. Nobody gives a shit. Getting the fucking compiler to work is more important that your crappy organisation.
It has "How to install multiple versions of GCC" but not "How to install GCC" AAAARGH!
And can I install GCJ without GCC? Can I buggery. So it another godknowshowmany megabytes to do one simple thing.
edit: oh wait I can. Nice of them to tell me that before I got to the last page in this whole maze of crap.

The installation procedure itself is broken into five steps.

1. Downloading the source
2. Configuration
3. Building
4. Testing (optional)
5. Final Install
Get a fucking auto-installer. Wankers. I don't want to have to compile my own sodding compiler.

And as if thats not enough, they go and make it imposible to download the files in the first place. The link to the download page takes you to a release history, and you then have to read 4 paragraphs of Boring Geek Shit(tm) to find the one tiny little link to the mirror list, which takes you to a stupid goddamn ftp thing. use http and one hyperlink ffs!
And to top it all off, zipped archives are bloody good enough, they have to make them *.tar.gz as well. "hnu hnu, but we saved you 500kb, hnu hnu". It's 17.5 MB, 18MB wouldn't take overmuch longer and it saves me a double unzipping process.

Also, Times New Roman blows goats.

02-05-2003, 22:00:30
Welcome to l33t-t0wn. Its like that to keep you n00bs and lightweights away. Only serious dedicated hardcores will stick to it...

Immortal Wombat
02-05-2003, 23:07:25
and welcome.

Sir Penguin
03-05-2003, 04:25:43
Actually, it's, "gnu gnu, you shouldn't be using m$ windoze, gnu gnu." :rolleyes:


03-05-2003, 04:32:48
Preach it, Penguin!

05-05-2003, 07:59:04
Tarballs can be unzipped in a single step. Just say "tar -xzf somefile.tar.gz". :)

While GCC is the first thing I'd use to compile C code in Linux, it's not my first choice for compiling Java. Sun and IBM should both have JDKs for various platforms including Windows. Installing GCC from souce on Windows is probably painful. Installing the JDK on Windows is easy.

Sir Penguin
05-05-2003, 08:19:33
I don't know of a way to get source code from a .class file. The javap tool, which comes with the SDK, outputs something somewhere between bytecode and source. There might be a script somewhere out there that can translate javap output to source code.


05-05-2003, 08:27:36
Now that I think about it, I don't know if that tar tip would work with anything besides GNU tar. In any event, you could say "gunzip < somefile.tar.gz | tar xf -" on any sensible UNIX.

Sir Penguin
05-05-2003, 08:46:31
And on Windows, PowerArchiver will let you delve into .tar.gz and .tar.bz2 files in similar fashion to .zip files.


Immortal Wombat
05-05-2003, 11:50:35
Well anyway, I got something working. I think it was a Sun JKD but I've got so much crap here I've lost all hope of figuring out what works why... So I can now turn *.class files into *.java files, mess with the code and turn them back into *.class files.

But now there's another problem :dance:

Because I've got 19 interrelated files, I can't change them from java to class files until the ones they look up their functions from are already class files. But I can't make them class files because the depend on the other ones - it's a big circle.

Sir Penguin
06-05-2003, 00:07:31
Sounds like you need to reorganise it. :)


Immortal Wombat
08-05-2003, 22:05:55
What's a CLASSPATH and how do I fix it?