• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Getting the code of a .exe file

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there anyway to get the java code from a .exe file?

thanks
 
Saloon Keeper
Posts: 13280
292
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only if the executable was compiled from Java code and you have a matching decompiler. Even then, decompiling it will not yield the original code because a lot of information has been lost during compilation.
 
Kevin O'Sullivan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Only if the executable was compiled from Java code and you have a matching decompiler. Even then, decompiling it will not yield the original code because a lot of information has been lost during compilation.



Thanks

How would I find out if it was complied from java code or not?
 
Stephan van Hulst
Saloon Keeper
Posts: 13280
292
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It probably wasn't.

Java projects are usually compiled to .class or .jar files, which are then run on a JVM. Even if it is a .exe, it's probably just a simple wrapper around a bunch of .class and .jar files, written in a different language such as C++.

To find out if there's anything Java related in the executable, you could open the executable with a hex editor and do a search for the magic number CAFEBABE, which gets compiled into .class files. It might not be present though if the class files were compressed in some way.

Why are you trying to do this in the first place?
 
Kevin O'Sullivan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:It probably wasn't.

Java projects are usually compiled to .class or .jar files, which are then run on a JVM. Even if it is a .exe, it's probably just a simple wrapper around a bunch of .class and .jar files, written in a different language such as C++.

To find out if there's anything Java related in the executable, you could open the executable with a hex editor and do a search for the magic number CAFEBABE, which gets compiled into .class files. It might not be present though if the class files were compressed in some way.

Why are you trying to do this in the first place?



I was doing a testing course last year and one of the assignments had .exe file (command line program) and we had to come up with test cases to try and break the program and then test the program with said test cases but I was always interested to see what the code looked like to see how it worked, it was theatre program where you could book seats etc and worked on the command line, what you said about it being written in a different language not necessarily java makes sense, I just assumed it was java for some reason.
 
Stephan van Hulst
Saloon Keeper
Posts: 13280
292
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could try a C++ decompiler and see what you get.
 
lowercase baba
Posts: 13003
66
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:you could open the executable with a hex editor and do a search for the magic number CAFEBABE


on a unix system, you could just use the "strings" command and a grep.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic