错误:无法加载主类清单属性
当我在我的电脑上安装 mysql-connector-java-5.1.15-bin 时,它给我一个错误,例如:无法加载主类清单属性
。请问您能告诉我应该做什么来消除这个错误吗?如果没有 mysql-connector-java-5.1.15-bin,我将无法执行任何操作,所以请尽快告诉我。
When I am installing mysql-connector-java-5.1.15-bin on my PC, it gives me an error such as: failed to load main-class manifest attribute from
. Please can you tell me what should I do to remove this error? I'm not able to do anything without mysql-connector-java-5.1.15-bin, so please tell me as soon as possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您正在尝试运行 JAR 文件,就好像它是可执行 JAR 文件一样(通过双击它或使用
java -jar mysql-connector-...jar 等命令运行它代码>)。
这不是您应该对这个 JAR 文件执行的操作。您只需要将其添加到项目的类路径中即可;不要尝试解压或运行它。它不包含安装程序。
背景信息:
可执行 JAR 文件包含一个
META-INF/MANIFEST
文件,其中包含Main-Class
等属性,这些属性告诉 Java 在运行 JAR 时要运行的类是什么文件。如果 JAR 文件不包含清单文件,或者包含不具有Main-Class
属性的清单文件,则它不是可执行 JAR 文件。It sounds like you are trying to run the JAR file as if it is an executable JAR file (either by double-clicking on it or running it with a command like
java -jar mysql-connector-...jar
).That's not what you are supposed to do with this JAR file. You just need to add it to the classpath of your project; don't try to unpack it or run it. It doesn't contain an installation program.
Background information:
Executable JAR files contain a
META-INF/MANIFEST
file that contains attributes such asMain-Class
that tell Java what the class to run is when you run the JAR file. If the JAR file doesn't contain a manifest file, or contains a manifest file that doesn't have aMain-Class
attribute, then it is not an executable JAR file.出现两个问题:1)mysql-connector-java 应该有一个主类吗? 2)你打算如何安装它?
1) 不。它只包含用于与 mysql 交互的 JDBC 类。
2)由于出现主类属性错误,您似乎双击了 jar 文件。
为了能够使用它,您必须将 jar 文件添加到您的类路径中。
Two questions come up: 1) Is mysql-connector-java supposed to have a main class? 2)how are you trying to install it?
1) No. It it only contains JDBC classes for interacting with mysql.
2) since you get main-class attribute errors you seem to be double clicking on a jar file.
To be able to use it you have to add the jar file to your classpath.