This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Getting the code of a .exe file

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anyway to get the java code from a .exe file?

thanks
 
Saloon Keeper
Posts: 11188
244
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 55
  • Mark post as helpful
  • send pies
  • 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: 11188
244
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 55
  • Mark post as helpful
  • send pies
  • 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: 11188
244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try a C++ decompiler and see what you get.
 
lowercase baba
Posts: 12792
51
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!