简体   繁体   English

找不到类错误,但是类在类路径中的JAR文件中

[英]Class not found error, but class is in JAR file on classpath

When calling a Java class from command line Java can't find the executable class, even though it's in a JAR file on the class path. 从命令行调用Java类时,Java找不到可执行类,即使它位于类路径上的JAR文件中。 I was getting this from a call within a Python script, but the same behavior happens on command line (DOS on Windows). 我是从Python脚本中的调用中得到的,但是在命令行(Windows上的DOS)中也会发生相同的行为。 Can anyone advise? 有人可以建议吗?

c:\nco> java -mx1200m -cp C:\tmp\lib\indices-0.0.2-SNAPSHOT.jar nidis.indices.GriddedIndexCalculator 

Error: Could not find or load main class nidis.indices.GriddedIndexCalculator

c:\nco> jar -tf C:\tmp\lib\indices-0.0.2-SNAPSHOT.jar | find "GriddedIndexCalculator"

nidis/indices/GriddedIndexCalculator.class

Java omits the classpath variable when you run it with java -jar due to security reasons. 由于安全原因,当使用java -jar运行Java时,Java会忽略classpath变量。

The solution is to define the dependencies in the Class-Path: attribute of your MANIFEST.MF file. 解决方案是在MANIFEST.MF文件的Class-Path:属性中定义依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 "即使在类路径中的 Jar 中也找不到类" - Class not found even when in Jar in the classpath 即使jar在classpath上,也无法找到类异常/调试classpath问题 - Class not found exception even if the jar is on the classpath / debugging classpath problems 添加admob jar文件和类未找到错误 - adding admob jar file and class not found error 按类名从类路径中的jar中提取类文件 - Extracting class file from jar in classpath by classname 设置jar和类的类路径 - Setting classpath for a jar and a class 如何在另一个jar文件的类路径中的jar文件中运行类 - how to run a class in the jar file which is in the classpath of another jar file 找不到类异常,即使在Mac OS X中放置了jar文件并设置了类路径之后 - Class Not Found Exception, even after putting the jar file and setting the classpath in Mac OS X Java Linux服务器:虽然在类路径中存在jar,但找不到类异常 - java linux server: class not found exception though jar in classpath Eclipse - JAR 创建失败“找不到类路径上的类文件或无法访问...” - Eclipse - JAR creation failed "Class files on classpath not found or not accessible for..." Eclipse导出到可运行的JAR-找不到或无法访问的类路径上的类文件: - Eclipse export to a runnable JAR - Class files on classpath not found or not accessible for :
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM