jar文件到底包含什么? [英] What exactly does a jar file contain?

查看:329
本文介绍了jar文件到底包含什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为实习生,我在我的项目中使用公司代码,他们通常会向我发送 jar 文件。我将它添加到 Eclipse 中的构建路径,通常一切都很好,花花公子。



然而,我很想知道每个类包含什么,当我尝试打开 jar 文件中的一个类时,它告诉我我需要一个源文件。



这是什么意思?我来自 C / C ++ 背景,所以 jar 类似于已编译的 .o 文件,我能看到的只是 .h 的东西?或者我使用的 jar 文件中是否存在加密的实际代码,因此我无法读取它?



<感谢所有答案!



编辑:
谢谢,伙计们,我知道这有点像档案但我很困惑为什么当我试图打开 .class 文件时,我得到了一堆随机字符。当我尝试在C中打开 .o 文件时,输出类似,所以我只是想确定。

谢谢!

解决方案

JAR文件实际上只是一个ZIP文件。它可以包含任何东西 - 通常它包含已编译的Java代码(* .class),但有时也包含Java源代码(* .java)。



但是,Java可以被反编译 - 如果开发人员混淆了他的代码,你将无法获得任何有用的类/函数/变量名称。


As an intern, I use company code in my projects and they usually send me a jar file to work with. I add it to the build path in Eclipse and usually all is fine and dandy.

However, I got curious to know, what each class contained and when I try to open one of the classes in the jar file, it tells me that I need a source file.

What does this mean? I come from a C/C++ background so is a jar similar to an already compiled .o file and all I can see is the .h stuff? Or is there actual code in the jar file that I'm using that's encrypted so I can't read it?

Thanks for all the answers!

Edit:
Thanks, guys, I knew it was a sort of like an archive but I was confused to why when I tried to open the .class files, I got a bunch of random characters. The output was similar when I tried to open a .o file in C so I just wanted to make sure.
Thanks!

解决方案

A JAR file is actually just a ZIP file. It can contain anything - usually it contains compiled Java code (*.class), but sometimes also Java sourcecode (*.java).

However, Java can be decompiled - in case the developer obfuscated his code you won't get any useful class/function/variable names though.

这篇关于jar文件到底包含什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆