简体   繁体   English

导出到JAR时LTI-Civil Project出现错误

[英]LTI-Civil Project wierd error when exported to a JAR

Outline: 1. My project uses LTI-CIVIL to capture webcam. 大纲:1.我的项目使用LTI-CIVIL捕获网络摄像头。 2. In Eclipse, everything works fine. 2.在Eclipse中,一切正常。 3. As LTI_CIVIL uses native libraries to access hardware, I have opted to use JarClassLoader (info found here http://www.jdotsoft.com/JarClassLoader.php#download ) which allows for the native libraries to be unpacked into a temporary folder at runtime. 3.由于LTI_CIVIL使用本机库访问硬件,因此我选择使用JarClassLoader(可在此处找到信息http://www.jdotsoft.com/JarClassLoader.php#download ),该文件允许将本机库解压缩到一个临时文件夹中在运行时。 Everything works great and I can even access the webcam capture stream until... I try to work with the Image handed in from the webcam which is of type com.lti.civil.NativeVideoFormat. 一切正常,我什至可以访问网络摄像头捕获流,直到......我尝试使用从网络摄像头上交的com.lti.civil.NativeVideoFormat类型的图像。 The problem is that when run from the executable jar, it says that this class does not implement com.lti.civl.VideoFormat when it obviously does. 问题在于,当从可执行jar运行时,它说此类显然没有实现com.lti.civl.VideoFormat。 I have even printed out the getClass() of the code running on eclipse and verified that the webcam Image is both of the same type. 我什至打印出了在eclipse上运行的代码的getClass(),并验证了网络摄像头图像是否是同一类型。 However, when I printout if the getClass() instanceof NativeVideoFormat, in the eclipse version this prints true, but in the jar version it prints false. 但是,当我打印出NativeVideoFormat的getClass()实例时,在eclipse版本中此打印为true,但在jar版本中则打印为false。

Interestingly, this problem has appeared before, but with no solution: https://forums.oracle.com/forums/thread.jspa?messageID=10637883&#10637883 有趣的是,此问题以前曾出现过,但没有解决方法: https : //forums.oracle.com/forums/thread.jspa?messageID=10637883&#10637883

Thanks for your help 谢谢你的帮助

You say that "it obviously does" implement that interface, but I think that the problem is that it actually doesn't. 您说“它确实可以实现”该接口,但是我认为问题是实际上并没有。 I think you have multiple "incarnations" of that interface type. 我认为您具有该接口类型的多个“信息”。

The real type of a class (or interface) at runtime depends is the identity of the Class object: 类(或接口)在运行时的实际类型取决于Class对象的身份:

  • If clazz == clazz2 then they represent the same type. 如果clazz == clazz2则它们表示相同的类型。 (The equals(Object) method on a Class tests the same condition ...) Class上的equals(Object)方法测试相同的条件...)
  • Otherwise they don't, irrespective of the class names. 否则, 无论类名如何 ,它们都不会。

It would appear that your application's use of classloaders has resulted in one .class file being loaded twice in two different class loaders. 看来您的应用程序对类加载器的使用导致一个.class文件在两个不同的类加载器中加载了两次。 I suspect that your JarClassLoader instance doesn't have the correct parent classloader. 我怀疑您的JarClassLoader实例没有正确的父类加载器。

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

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