Is decompiling / reverse engineering of someone's else JAR/WAR/EAR/... to peek into code is ethical? [Open Sourced / "Closed" Sourced]
Say you are using some JAR, which is not good documented OR you need to see what's happening "inside" for curiosity?
If it's open source software, you're much better off just getting the source (and documentation) and look at that. Not all information that's in the original source code files is retained in the class files, so decompilers never do a perfect job (you'll never get the exact, original source code back if you use a decompiler).
But even if you are borrowing code from an open source project, you have to carefully read and understand the license. Some open source licenses (such as GPL) require you to make the source code of your own program available if you use GPL software in your own program. And even if you're using open source software with a license that doesn't require you to open up your own program, it's at least a good idea to give credit to the people who wrote the open source software you use (don't steal code and pretend that you've written it yourself).
If it's closed source, it depends if it's legal or not. Some (most?) software licenses of commercial software expressly forbid reverse engineering, so if you do it, you're doing something illegal. Though the Wikipedia page says:
In the United States and many other countries, even if an artifact or process is protected by trade secrets, reverse-engineering the artifact or process is often lawful as long as it is obtained legitimately.
Ofcourse, stealing code (that you've obtained via reverse engineering or other ways) from a commercial product is illegal.