ArnoHlaMoe
ArnoHlaMoe

Reputation: 287

How can I remove unnecessary whitespace from Java source?

I've seen jquery.min.js and some CSS files with all unnecessary whitespace removed from them. Is there a tool available to do same with Java source for obfuscation purposes?

Upvotes: 0

Views: 453

Answers (2)

DwB
DwB

Reputation: 38300

Here is the best way to make your java code unreadable: do not publish your java code.

If you must publish your java code, do not obfuscate it.

There are exactly zero good reasons to obfuscate your java code.

Upvotes: 2

Peter Lawrey
Peter Lawrey

Reputation: 533492

yeah, I wanna unreadable

You shouldn't need to provide the original source, you would compile it to byte code as this can be run on any Java platform.

The byte code for compiled code is already difficult to read but it can be decompiled. You can make it difficult to decompile with a byte code obfuscator.

There are several (commercial and free)

https://www.google.co.uk/search?q=java+obfuscator

This changes the byte in ways that the JVM can read but is not easily read as the original Java or produce compileable code. e.g. turn fields names into numbers etc.

BTW: You can always reverse engineer the code, but you can make it harder to do.

Upvotes: 3

Related Questions