编译时如何通配符包含 JAR 文件?

How to wildcard include JAR files when compiling?(编译时如何通配符包含 JAR 文件?)
本文介绍了编译时如何通配符包含 JAR 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我在 java 文件 (MyRtmpClient.java) 中有以下内容:

I have the following in a java file (MyRtmpClient.java):

import org.apache.mina.common.ByteBuffer;

ByteBuffer 位于 JAR 文件中(当然具有正确的目录结构).该 jar 文件和我需要的其他文件与 .java 文件位于同一目录中.

and ByteBuffer is inside a JAR file (with the proper directory structure of course). That jar file and others I need are in the same directory as the .java file.

然后我用这一行编译:

javac -cp ".;*.jar" MyRtmpClient.java

但我得到了错误:

MyRtmpClient.java:3: 包 org.apache.mina.common 不存在
导入 org.apache.mina.common.ByteBuffer;

如何在我的项目中包含 jar 文件?

How can I include jar files in my project?

推荐答案

你的命令行是正确的,但是有一些注意事项:

your command line is correct, but there are some considerations:

  • 您必须拥有 javac >= 1.6,因为只有在该版本中,编译器才会将*"解析为各种 JAR 文件.
  • 您必须运行 Windows,因为;"仅是该操作系统的路径分隔符(它在 Unix 上不起作用,Unix 上的路径分隔符是:").

我假设 JAR 文件具有您所说的正确目录结构.

I'm assuming that the JAR file has the proper directory structure as you stated.

这篇关于编译时如何通配符包含 JAR 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

相关文档推荐

How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)