如何从Eclipse插件链接Z3 build,Compiled for Java?

时间:2017-10-08 12:08:09

标签: eclipse-plugin z3

我有一个完美的Java Z3 Build系统。我想从Eclipse插件中调用它。我尝试了几种方法,但没有一种方法适合我。这些方法是:

  1. 将Z3 build添加为外部类文件夹 How to Use External Class Files in an Eclipse Project
  2.   

    线程中的异常" main" java.lang.UnsatisfiedLinkError:没有   java.library.path中的libz3java   java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)at   java.lang.Runtime.loadLibrary0(Runtime.java:870)at   java.lang.System.loadLibrary(System.java:1122)at   com.microsoft.z3.Native。(Native.java:14)at   com.microsoft.z3.Global.ToggleWarningMessages(Global.java:87)at   TestZ3.main(TestZ3.java:9)

    1. 将Z3构建复制到根目录下的Eclipse插件。然后在Libraries下添加com.microsoft.z3.jar(右键单击项目 - > Build Path-> Configure Build Path-> Libraries-> Add Jars)。错误是:
    2.   

      java.lang.UnsatisfiedLinkError:java.library.path中没有libz3java   java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)at   java.lang.Runtime.loadLibrary0(Runtime.java:870)at   java.lang.System.loadLibrary(System.java:1122)at   com.microsoft.z3.Native。(Native.java:14)at   com.microsoft.z3.Global.ToggleWarningMessages(Global.java:87)at   plugintest.handlers.SampleHandler.execute(SampleHandler.java:37)at   org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:295)     在   org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:498)at   org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)     在   org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:252)     在   org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:234)     在   org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)     在   org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)     在   org.eclipse.core.commands.Command.executeWithChecks(Command.java:493)     在   org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:486)     在   org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)     在   org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:799)     在   org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:675)     在   org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access $ 7(HandledContributionItem.java:659)     在   org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem $ 4.handleEvent(HandledContributionItem.java:592)     在org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)     在org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)at   org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)at   org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4180)     在org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3769)     在   org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine $ 4.run(PartRenderingEngine.java:1127)     在   org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)     在   org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)     在   org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)     在org.eclipse.ui.internal.Workbench $ 5.run(Workbench.java:694)at at   org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)     在   org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)     在   org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)     在   org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)     在   org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)     在   org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)     在   org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)     在   org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)     在   org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:498)at   org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)at at   org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)at at   org.eclipse.equinox.launcher.Main.run(Main.java:1515)at   org.eclipse.equinox.launcher.Main.main(Main.java:1488)

      1. 无论是否有上一步,我都将com.microsoft.z3.jar添加到位于Plugin.xml Runtime选项卡的Classpath中。在这种情况下,插件没有找到按下按钮命令后调用的处理程序。
      2.   

        !无法找到MESSAGE plugintest.handlers.SampleHandler   PluginTest_1.0.0.qualifier!STACK 0 java.lang.ClassNotFoundException:   无法找到plugintest.handlers.SampleHandler ....更多

        事实上,这种方法适用于我以前的安装(戴尔,英特尔,x64,Eclipse Mars(x64),Java 1.8 x64)!

        1. https://github.com/Z3Prover/z3/issues/1093中讨论之后,我将com.microsoft.z3.jar的本地库位置配置为Z3 Build目录。从Eclipse插件调用Z3 Build,报告的错误与方法2中的相同,但是从Java应用程序调用它,错误更具体:
        2.   

          线程中的异常" main" java.lang.UnsatisfiedLinkError中:   C:\ Users ... TestZ33 \ build \ libz3java.dll:无法找到依赖库         at java.lang.ClassLoader $ NativeLibrary.load(Native Method)         在java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)         在java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)         在java.lang.Runtime.loadLibrary0(Runtime.java:870)         在java.lang.System.loadLibrary(System.java:1122)         在com.microsoft.z3.Native。(Native.java:14)         在com.microsoft.z3.Global.ToggleWarningMessages(Global.java:87)         在TestZ3.main(TestZ3.java:9)

          1. 其他https://www.chilkatsoft.com/java-loadlibrary-windows.asp
          2. 当您在Z3构建目录下拥有Java应用程序时,工作原理是什么。任何人都可以帮助如何使用Java应用程序或Eclipse插件中的Z3构建目录。顺便说一句,我按照方法#2,工作正常,直到我尝试复制它(因为我的笔记本电脑崩溃)并被迫使用另一台笔记本电脑,然后相同的程序对我不起作用(我之前有运气)。目前,新笔记本电脑具有以下设置:

            HP Laptop (AMD, x64)
            
            C:\Users\nmd02\git\resa_mars_workspace>java -version
            java version "1.8.0_144"
            Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
            Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
            

            路径:

              

            %SYSTEMROOT%\ SYSTEM32;%SYSTEMROOT%;%SYSTEMROOT%\ System32下\ WBEM;%SYSTEMROOT%\ System32下\ WindowsPowerShell \ V1.0 \; C:\程序   文件(x86)\ QuickTime \ QTSystem \; C:\ Program   文件\ MATLAB \ 2017A \运行\ Win64平台; C:\ PROGRAM   Files \ Java \ jdk1.8.0_144 \ bin; C:\ Program Files \ Git \ cmd; C:\ Program   FILES \ CMake的\ BIN; C:\ MinGW的\ BIN; C:\ python36; C:\用户...混帐\忍者; C:\ PROGRAM   文件(x86)\ Windows Kits \ 8.1 \ Windows性能   工具包\; C:\的GnuWin32 \ BIN

            我非常感谢您的帮助。

            干杯, / NAS

1 个答案:

答案 0 :(得分:2)

在运行时,您的代码需要找到com.microsoft.z3.jarlibz3.dll/.so/.dyliblibz3java.dll/.so/.dylib。 Java负责第一个,但操作系统必须找到其他库,即,必须设置运行代码的任何环境,以便PATH(Windows),LD_LIBRARY_PATH(Linux ),或DYLD_LIBRARY_PATH(OSX)指向库。另外,请确保您的Z3版本和您的Java版本都是32位或64位,否则您获得的错误消息可能信息量不大。

对于某些类型的Java,向JVM提供java.library.path设置可能也是必要或有帮助的。