• <tfoot id='9ladl'></tfoot>
    <i id='9ladl'><tr id='9ladl'><dt id='9ladl'><q id='9ladl'><span id='9ladl'><b id='9ladl'><form id='9ladl'><ins id='9ladl'></ins><ul id='9ladl'></ul><sub id='9ladl'></sub></form><legend id='9ladl'></legend><bdo id='9ladl'><pre id='9ladl'><center id='9ladl'></center></pre></bdo></b><th id='9ladl'></th></span></q></dt></tr></i><div id='9ladl'><tfoot id='9ladl'></tfoot><dl id='9ladl'><fieldset id='9ladl'></fieldset></dl></div>

        <small id='9ladl'></small><noframes id='9ladl'>

        <legend id='9ladl'><style id='9ladl'><dir id='9ladl'><q id='9ladl'></q></dir></style></legend>
          <bdo id='9ladl'></bdo><ul id='9ladl'></ul>

        如何使用 .jar 库编译 Java 程序

        How to compile Java program with .jar library(如何使用 .jar 库编译 Java 程序)
            • <bdo id='6d4sd'></bdo><ul id='6d4sd'></ul>
            • <legend id='6d4sd'><style id='6d4sd'><dir id='6d4sd'><q id='6d4sd'></q></dir></style></legend>

              <small id='6d4sd'></small><noframes id='6d4sd'>

                  <tbody id='6d4sd'></tbody>
                <tfoot id='6d4sd'></tfoot>
              1. <i id='6d4sd'><tr id='6d4sd'><dt id='6d4sd'><q id='6d4sd'><span id='6d4sd'><b id='6d4sd'><form id='6d4sd'><ins id='6d4sd'></ins><ul id='6d4sd'></ul><sub id='6d4sd'></sub></form><legend id='6d4sd'></legend><bdo id='6d4sd'><pre id='6d4sd'><center id='6d4sd'></center></pre></bdo></b><th id='6d4sd'></th></span></q></dt></tr></i><div id='6d4sd'><tfoot id='6d4sd'></tfoot><dl id='6d4sd'><fieldset id='6d4sd'></fieldset></dl></div>

                  本文介绍了如何使用 .jar 库编译 Java 程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我无法让 javac 识别外部 .jar 文件,我正在尝试扩展其类.我在同一个目录中有两个文件:TestConsole.java 和 acm.jar.我正在使用以下命令从同一目录编译:

                  I can't make javac recognize an external .jar file, whose classes I'm trying to extend. I have two files in the same directory: TestConsole.java and acm.jar. I'm compiling from the same directory using the following command:

                  javac -classpath .:acm.jar TestConsole.java

                  但似乎 javac 只是忽略了 acm.jar.它给了我错误:

                  But it seems like javac is just ignoring acm.jar. It gives me the error:

                  TestConsole.java:1: package acm does not exist
                  import acm.program;
                            ^
                  

                  当然,acm.program 是 acm.jar 中的一个包.acm.jar 中的所有类都已编译;我只想在我的类中使用它们,而不是编译它们.

                  Of course, acm.program is a package in acm.jar. All of the classes in acm.jar are already compiled; I just want to use them in my classes, not compile them.

                  我做错了什么?

                  我在 Mac 上运行它,acm.jar 的目录结构似乎是有效的:它包含一个 acm/program 目录,其中包含 ConsoleProgram.classTestConsole 扩展的唯一类.

                  I am running this on a Mac, and the directory structure of acm.jar appears to be valid: It contains an acm/program directory, which has ConsoleProgram.class, the only class that TestConsole extends.

                  javac -classpath ".:acm.jar" TestConsole.java 也不起作用.

                  推荐答案

                  检查清单:

                  1. 您在 acm.jar 中的类显示为:

                    acm/program/CLASSX.class

                    acm/program/CLASSY.class

                  1. your classes in acm.jar appear as:

                    acm/program/CLASSX.class

                    acm/program/CLASSY.class

                  当用 jar tf acm.jar 倒出时

                  when decanted with jar tf acm.jar

                  您正在像这样导入它们:

                  You're importing them like:

                  导入 acm.program.CLASSX ;

                  导入 acm.program.* ;

                  import acm.program.CLASSX ;

                  or

                  import acm.program.* ;

                  这篇关于如何使用 .jar 库编译 Java 程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Compiling C++ for the JVM(为 JVM 编译 C++)
                  Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                  How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                  Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                  How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                  Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)

                          <bdo id='wgl2C'></bdo><ul id='wgl2C'></ul>
                        • <i id='wgl2C'><tr id='wgl2C'><dt id='wgl2C'><q id='wgl2C'><span id='wgl2C'><b id='wgl2C'><form id='wgl2C'><ins id='wgl2C'></ins><ul id='wgl2C'></ul><sub id='wgl2C'></sub></form><legend id='wgl2C'></legend><bdo id='wgl2C'><pre id='wgl2C'><center id='wgl2C'></center></pre></bdo></b><th id='wgl2C'></th></span></q></dt></tr></i><div id='wgl2C'><tfoot id='wgl2C'></tfoot><dl id='wgl2C'><fieldset id='wgl2C'></fieldset></dl></div>
                          <tfoot id='wgl2C'></tfoot>

                            <tbody id='wgl2C'></tbody>
                          • <small id='wgl2C'></small><noframes id='wgl2C'>

                            <legend id='wgl2C'><style id='wgl2C'><dir id='wgl2C'><q id='wgl2C'></q></dir></style></legend>