As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
How to get java file i.e source code from class file i.e from compiled file?
Check out this Java Decompiler.
Also see this Wikipedia page to know more about decompilation.
It should be noted that the code you get on decompilation of bytecode isn't very readable.
You have to use a disassembler.
Java Decompiler is a good choice.
Also Java Decompiler has a plug-in for Eclipse.
You can use javap command to get the overall structure of the file.
On the side note: Best way to disable anyone from getting the source from your compiled code is to use obfuscation.
You can make use of javap for getting the source back from bytecode.
There are plenty of tools and plugin that help you to disassemble and you can find some discussed here.
Yes you cannot do anything like reverse conversion.
What you can do is modify the bytecode at runtime. That's allowed in Java...
Check for java.lang.instrumentation package. That will help you to achieve your goal to some extent...
I just published a stand-alone Java Decompiler GUI (based on Jad) which you can get from Util Java Decompiler (JAD based) v1.0
This is a Windows based .NET 4.0 application, which supports the drag n'drop of *.jar files.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
So I've just realized how easy it is to decompile my Java code. I've been searching around the net and I can't seem to figure out WHY its so easy. Every time I google something like "Why can I decomilple .class files?" or "Why does Java decompile so easily", all I get is links to software that can easily deompile my code. So I turn to you StackOverflow: why is it that Java can be converted back to easlily readable source code while C++ and other languages aren't very friendly to decompiling?
Thanks
Because Java byte-code is closer (more similar) to the source than assembly.
In particular, .class files include metadata for classnames, method names, field & parameter types, etc...
All a Java (or .Net) decompiler needs to do is look at the instructions in each method body, and turn them into the appropriate syntactic constructs.
By contrast, native languages like C++ do not include any metadata at all, so the decompiler needs to reconstruct everything.
Java is compiled into an intermediate form, JVM bytecode, that retains a large amount of the information contained in the original Java code. A language like C++ compiles into assembly code, with looks a lot different from the original code, and is, therefore, harder to reverse.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I need a standalone Java parser (program which "reads" .java source files and generates AST [ie objects representing the contents of source]).
There's https://code.google.com/p/javaparser/ but it supports only Java 1.5
I know how to run Eclipse Java parser in "standalone" mode, but this parser uses too many Eclipse JARs, is too complex, and uses EPL license, which is GPL-incompatible
other IDEs (IntelliJ, NetBeans, JDeveloper) and javac compiler also must have some Java parsers, but I can't find any documentation how to use them in "standalone" applications
Any help? Maybe somebody of You also tried to do some standalone Java parsing?
Our DMS Software Reengineering Toolkit has a full Java 1.7 parser. But a parser isn't enough, if you intend to anything serious; check out Life After Parsing. DMS has the support you need beyond that to process Java interestingly, such as , attribute grammars, symbol tables, transformation rules, etc, plus good documentation for all of that. DMS is designed to support the construction of custom langauge analysis tools. It isn't GPL-compatible, though.
JavaCC has a Java 1.5 grammar.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
So I've just realized how easy it is to decompile my Java code. I've been searching around the net and I can't seem to figure out WHY its so easy. Every time I google something like "Why can I decomilple .class files?" or "Why does Java decompile so easily", all I get is links to software that can easily deompile my code. So I turn to you StackOverflow: why is it that Java can be converted back to easlily readable source code while C++ and other languages aren't very friendly to decompiling?
Thanks
Because Java byte-code is closer (more similar) to the source than assembly.
In particular, .class files include metadata for classnames, method names, field & parameter types, etc...
All a Java (or .Net) decompiler needs to do is look at the instructions in each method body, and turn them into the appropriate syntactic constructs.
By contrast, native languages like C++ do not include any metadata at all, so the decompiler needs to reconstruct everything.
Java is compiled into an intermediate form, JVM bytecode, that retains a large amount of the information contained in the original Java code. A language like C++ compiles into assembly code, with looks a lot different from the original code, and is, therefore, harder to reverse.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I'm currently working on a Java/Flex project and I'm looking for a way to generate some parts of my Actionscript code from my Java files.
One of the goal is to generate the AS valueObjects from the JAVA transferObject as well as some AS code to access the serverside function asynchronous.
And other important point is that I want to be independent of some IDE. The code generation should run from Maven or Ant and take the Java source code as input.
I looked a little bit around and found stuff like SpringROO, Groovy-GRAM, AST in eclipse,.. The guys from graniteDS do their code generation more or less the way I want to do it.
Thanks for any help or suggestions
I use now xText:
I created my one meta-model (grammar) from which I generate an eclipse editor plug-in. This plug-in helps me to create the textual model.
From the concrete model, I generate with xpand and xtend the Java and Actionscript code
Thanks all for your help.
You can use MTASC for command-line AS compiling.. It's an open-source command-line actionscript compiler. It produces swf files which can be loaded by your AS code.
Update:
For Java to AS compilation use J2AS.
Because you want an independent generator, AtomWeaver could be an option. It's a standalone tool with no other dependencies. It does not have a command-line option (it's IDE-like).
It's great if you want to build your own code generator using templates, but if you want a already-made generator then you're out of luck...
look at flexmojos project https://docs.sonatype.org/display/FLEXMOJOS/Home
it's a maven plugin for flex, you can specify a "generate" target and maven generates your vo from java files. https://docs.sonatype.org/display/FLEXMOJOS/Generator+Mojo
GraniteDS GAS3 is a good one for generating ActionScript code for vaule object.
The code generation can be customized using the groovy template.
http://www.graniteds.org/confluence/display/DOC/3.+Gas3+Template+Language
It integrates nicely with Eclipse IDE and also has ant and maven plugins
We use our web service xsds that define the types to auto generate our java transfer objects as well as our actionscript value objects using Freemarker. Hope this helps.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
It doesn't have to be full blown of course, and console output only would be enough. I'd like it to be able to work on some program parts on any PC which has internet connection.
I'm really looking for a lightweight IDE I can also use for quick tests
You can use ideone.com - it serves a simple java (and many more languges) compiler and executions environment.
http://cloud-ide.com is probably your best option for Java development.
Check http://www.cloud-ide.com indeed
With Java Debug Online capabilities as viewable in that video http://vimeo.com/40872612
I've been working on my own online java editor. Check it out and let me know what you think!
Ceclipse is an online Java IDE which supports Firefox and Chrome.
They say that Eclipse might provide that in their next version.
[update - 2016]
Eclipse cloud IDE avaiable at http://www.eclipse.org/che/
Not sure if it's exactly what you're looking for, but Bespin is an online editor that looks interesting...
Try this http://www.innovation.ch/java/java_compile.html
There is an online editor for any FTP server. It's tageted to PHP (bacause it's the common way to work with PHP), but you can use it for java too.
http://online-php.com