简体   繁体   中英

How to compile java files in jar to byte code (*.class file)

如何将jar文件中的java文件编译为字节码(*.class文件)?

A jar file is just an archive. You have to extract the java source files in order to compile them.

Since a jar is an archive of java-related files and perhaps metadata, they can really hold just about anything. They are just zip archives with a different name. Typically you find "regular" jar's (containing .class files) and source jar's (containing .java files).

It sounds like you might have a source jar and you need the regular jar that contains the compiled classes. If this is a jar you've downloaded from someplace, perhaps you should look for it's compiled counterpart. If this is a jar that you've built yourself, then you skipped the compile step and built yourself a source-jar.

If it is none of the above, then, like others have pointed out, unzip it and compile the classes. Just know that there may be other hurdles involved when it comes to satisfying all the jar's dependencies. Unless, it came with a pom for you to use or reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM