简体   繁体   English

系统范围Jar抛出类未找到异常

[英]System Scope Jar Throws Class Not Found Exception

My project uses javafx jar and includes it through system scope in maven. 我的项目使用javafx jar,并通过maven中的系统范围将其包括在内。 It works fine in my local. 在我当地的地方效果很好。 Now, since the jar is included through system scope, it is not included in the fat jar and when, I deploy that fat jar, it is giving ClassNotFound Exception for javafx class. 现在,由于该jar包含在系统范围内,因此它不包含在胖jar中,当我部署该胖jar时,它将为javafx类提供ClassNotFound Exception。 Why is it not able to access that javafx jar on the machine where I deployed the project, since, the javafx is located in the same lib folder in that machine also? 为什么javafx也位于该机器的同一个lib文件夹中,所以为什么无法访问我部署了该项目的机器上的javafx jar?

PS: I manually copied javafx jar to that machine on the JAVA_HOME/lib/ folder. PS:我将javafx jar手动复制到JAVA_HOME / lib /文件夹中的该计算机上。

Update: Just noticed that running the jar from the local itself, is throwing that error, though running fine from eclipse. 更新:刚刚注意到从本地运行jar会抛出该错误,尽管从eclipse运行良好。

There could be a number of reasons why this is occurring: 发生这种情况可能有多种原因:

1.) When you copied in the javafx jar, the permissions are wrong so that it is not readable by the process running your java program. 1.)在javafx jar中复制时,权限错误,因此运行Java程序的进程无法读取它。

2.) The user that is running your java program does not have the JAVA_HOME/lib folder on the classpath. 2.)运行Java程序的用户的类路径上没有JAVA_HOME / lib文件夹。 This can happen if you run your program as say a service-level user, but installed java as another user. 如果您以服务级别用户的身份运行程序,但以另一个用户身份安装了Java,则会发生这种情况。 Sometimes the JAVA_HOME may not be set for the other user in their profile. 有时,可能未在其个人资料中为其他用户设置JAVA_HOME。

3.) Different versions of your target jar may move classes around, such that running with version 1.0 will work, but 2.0 will result in a class not found exception because the class has been moved to a new package. 3.)不同版本的目标jar可能会移动类,以使版本1.0可以运行,但是2.0将导致找不到类的异常,因为该类已被移至新软件包。 Make sure you are have the same version of the javafx jar in both places. 确保两个地方都有相同版本的javafx jar。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM