8

Is there a tool out there for minifying java source code?

I am aware there is not much practical need for such a tool, but I am interested to reduce some students' code to 'bare bones' to show how their variable names are interpreted (sort-of -- it will heopfully re-enforce that their choice of variable names are disregarded) by the compiler. (The next step in this pedagogical process might be to show them the compiled code).

Thanks.

5
  • 1
    For Java source? I don't know of any. ProGuard deals with bytecode. Commented Nov 29, 2012 at 21:54
  • 1
    I'm not so sure that would be such a good example of how the compiler interprets variable names. Commented Nov 29, 2012 at 21:57
  • A similar question was already discussed here: stackoverflow.com/questions/2537568/best-java-obfuscator Like @dystroy said, Progard is the most popular one. Commented Nov 29, 2012 at 22:06
  • related: stackoverflow.com/questions/12154553/… Commented Nov 30, 2012 at 15:17
  • this stackoverflow.com/questions/1967987 is also related. In particular, spoon.gforge.inria.fr seems to be a good base for this kind of source-to-source transformation. Commented Aug 19, 2014 at 12:52

1 Answer 1

9

In the java world we mostly speak, due to the purpose, of obfuscation (even if in my opinion the impact on application file size can be useful, I used it a lot on Android applications a few years ago).

The best java obfuscator is probably Progard. Like all of them, it can reduce all (non exported) class and/or variable names to just a letter, which is part of the obfuscation as well as part of a minification.

You will have to decompile the bytecode afterwards if you want to show some java.

Sign up to request clarification or add additional context in comments.

2 Comments

Can I use Progard for commercial product?
ProGuard optimizes/obfuscates bytecode and not Java source.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.