This site requires JavaScript, please enable it in your browser!
Greenfoot back
Peractin
Peractin wrote ...

2012/1/22

Greenfoot and Java Questions

Peractin Peractin

2012/1/22

#
Hello All, I'm new to Greenfoot and Java programing. I see that Greenfoot can be used to make games which is cool and all but, does this lead up to being able to make actual Windows type applications? I was also wondering, does anyone know how to reverse engineer a Java program back to it's source code or if this is even possible? I have an older Java game based off from a real game that I and lots of other people still play. The problem is that the creator of this game mysteriously disappeared a few years ago but, the real game is still having new elements added to it with no way of updating those elements in the Java game because no one but the creator has the source code. One of the reasons I decided to start to learn Java was for this game, to either learn to break it down so that I can add the updates or just attempt to start from scratch and make the game all over again. Thanks for any help.
Morran Morran

2012/1/23

#
Yes, Greenfoot helps you for any programming that you need to learn. Greenfoot is real Java programming. Once you feel like you have mastery over Greenfoot, you can take the same things that you've learned and apply them to other programming languages. If you're interested in learning how to program anything, I think that Greenfoot is the best place to start. I do not believe that you can reverse engineer that game and get its source code, or even if that's allowed. It seems better to build the game again from scratch. When you do, you can add your own little touches, to make it even better than you remember.
mjrb4 mjrb4

2012/1/23

#
Greenfoot provides a framework for creating simulations / games and suchlike easily, but it doesn't restrict you to just use those classes, you have everything in the JDK available to you. Moreover it'll teach you the basics of Java syntax and object orientation which will make developing desktop Java applications easier than starting entirely from scratch that way. In terms of this game, legally the answer is probably not, though there are some licenses that do allow reverse engineering - you'll have to look at the details. Technically it depends how the class was compiled - if it was compiled *normally* then it would likely be rather easy to extract the source from the class file. The static Java compiler is deliberately quite "dumb" and does a near literal translation of the code these days, the reason being this is much better for the JIT which can make much bigger optimisations at runtime. Of course there are obfuscators though, and if the code was run through one of them then it wouldn't be worth trying to reverse engineer it - the only way to find out would be to have a peek at the code.
MeCanta MeCanta

2012/1/23

#
I have an older Java game based off from a real game that I and lots of other people still play. It seems to me that "Java game" in the above quote doesn't equal "Greenfoot scenario".
mjrb4 mjrb4

2012/1/23

#
It seems to me that "Java game" in the above quote doesn't equal "Greenfoot scenario".
It makes no difference. Both compile to class files...
sp33dy sp33dy

2012/1/23

#
It is possible to decompile java classes and it isn't as scarey as people think. If an obfuscator has been used, it is a lot harder to read the code. However, it will compile and run! You'd have to learn what variables are what (obfuscating is the process of reducing the variable names, functions and classes to difficult to read form). I would recommend looking at JAD (although it is unsupported now) or a similar product. However, before you can decompile, you really should know Java inside and out..
mjrb4 mjrb4

2012/1/23

#
obfuscating is the process of reducing the variable names, functions and classes to difficult to read form
Modern obfuscators do a lot more than that - they can refactor your code into different methods, put random empty loops in and variables that aren't used, replace known operations with more obfuscated ones that do the same thing... if code is run past a good obfuscator it becomes for the most part completely impractical to try and extract something close to the original. It can be done of course (or more accurately, it can be manipulated back into some form of readable code) but it's almost never worth it, and almost always illegal anyway.
sp33dy sp33dy

2012/1/23

#
I agree mjrb4, if someone has run the code through that powerful level of processor. However, the code will always execute; therefore if you really want to, you can work the code out (especially when use in debug mode to trace what the 'good' path is). It'll be very complicated mind you! Given Peractin mentions the author disappeared a few years ago and I added another year or so to the app creation date; I assume it probably hasn't gone through such a powerful obfuscator (if one at all). I could be wrong. The best way to find out is try decompiling and see! It amazes me how many product based java applications decompile. In fact, it was one reason that put me off writing commercial games in Java. Not that I've written a commercial game! lol
mjrb4 mjrb4

2012/1/23

#
Sure, it may not have gone through one at all - and if not it should be easy (technically) to decompile. And yes you'll always be able to work some meaningful code out eventually - but often it's just not worth doing if it's that hard a task. Again to reiterate though check the license because however technically easy it may be, legally it may well be a no go (and just because the author has disappeared doesn't mean he won't notice someone reverse engineering and publishing his works!)
sp33dy sp33dy

2012/1/23

#
The last point is critical! You don't want to be messing about with licenses; you are better off trying to contact the author or the publisher.
Peractin Peractin

2012/1/24

#
Thank you, everyone for the information. I see that I just need to learn more about Java programing to understand these things. The game that I would like to either edit or recreate does not have any license with it. It was just something someone made up to compliment the real world game. As far as decompiling "class" files for the game, I looked and I do not see any of these. The game is run with a ".exe" file and there is a ".jar" file with the same name. All the other files are data files containing the data that makes up the game items. I tried to open both the ".exe" file and the ".jar" file with Greenfoot and it gave me a warning about a Greenfoot program older than version .5 was used to make this program and that manual corrections would have to be made. When it opened I had a blank screen and nothing seemed to be there from the program.
sp33dy sp33dy

2012/1/24

#
A jar file is much like a Zip file, i.e. JAR -> Java ARchive. So, if you have winzip or winrar (or such tool) installed, you can open the .jar in the tool. You should then find the .class files (and possibly, but unlikely the .java) files in the sub folders. Often, java code is developed with package names, these map to folders, i.e. Java.awt.Color would be java/awt/color folders for instance. As for the .exe, well, that's just an executable which is probably boot strapping the java code. I.E. setting up environmental variables and then asking java to start. I cant remember which version of java (either 6 or 7), the introduction of executable jar's was introduced, deeming the bootstrap code redundent. In fact, I'm sure it was v6.
mjrb4 mjrb4

2012/1/24

#
From your replies and as you suggest, I'd seriously consider looking more at basic Java programming in general before trying to tackle this (if you choose to) - tackling it with only a limited understanding will likely just leave you frustrated and with no end result!
davmac davmac

2012/1/25

#
The game that I would like to either edit or recreate does not have any license with it.
Then you certainly don't have permission to redistribute derivative works (including anything you get by first decompiling the original). The only thing that would let you do that is some kind of license. If you re-create the game from scratch you are on slightly firmer ground but you could still be infringing copyright if you use images/sounds/etc from the original game, or infringing trademarks if you use the orginal name of the game etc.
You need to login to post a reply.