Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当它所依赖的类不在类路径中时,将类导出为 .jar 是否可能且正确。具体来说,我正在使用 eclipse 将类导出为 jar 文件,而依赖类不在类路径中。
如果 Java 类可以编译,您可以将 .class 文件放入没有依赖关系的 JAR 中。
如果您的类中有编译错误,Eclipse 仍然允许您将类导出为 jar(有一个复选框,您可以在导出时选中它以允许这样做),但这将不可用。由于该jar文件主要包含的.class文件不过是编译后的源文件(.java文件)。
jar
.class
.java