QtJambi和Jython

时间:2010-06-24 21:58:17

标签: jython qt-jambi

我试图让QtJambi和Jython一起玩得很好。这是我正在做的测试:

>jython -Dpython.path=./qtjambi-4.5.2_01.jar:./qtjambi-linux64-gcc-4.5.2_01.jar:.
Jython 2.2.1 on java1.6.0_18
Type "copyright", "credits" or "license" for more information.
>>> from com.trolltech.qt.gui import *
>>> dir(QApplication)
['aboutQt', 'aboutQtJambi', 'activeModalWidget', 'activePopupWidget', 'activeWindow', 'alert', 'allWidgets', 'beep', 'changeOverrideCursor', 'clipboard', 'closeAllWindows', 'colorSpec', 'commitData', 'commitDataRequest', 'cursorFlashTime', 'desktop', 'desktopSettingsAware', 'doubleClickInterval', 'exec', 'focusChanged', 'focusWidget', 'font', 'fontDatabaseChanged', 'fontMetrics', 'fromNativePointer', 'globalStrut', 'initialize', 'inputContext', 'instance', 'isEffectEnabled', 'isLeftToRight', 'isRightToLeft', 'isSessionRestored', 'keyboardInputDirection', 'keyboardInputInterval', 'keyboardInputLocale', 'keyboardModifiers', 'lastWindowClosed', 'layoutDirection', 'mouseButtons', 'notify', 'overrideCursor', 'palette', 'quitOnLastWindowClosed', 'restoreOverrideCursor', 'saveState', 'saveStateRequest', 'sessionId', 'sessionKey', 'sessionRestored', 'setActiveWindow', 'setColorSpec', 'setCursorFlashTime', 'setDesktopSettingsAware', 'setDoubleClickInterval', 'setEffectEnabled', 'setFont', 'setGlobalStrut', 'setGraphicsSystem', 'setInputContext', 'setKeyboardInputInterval', 'setLayoutDirection', 'setOverrideCursor', 'setPalette', 'setQuitOnLastWindowClosed', 'setStartDragDistance', 'setStartDragTime', 'setStyle', 'setStyleSheet', 'setWheelScrollLines', 'setWindowIcon', 'startDragDistance', 'startDragTime', 'style', 'styleSheet', 'syncX', 'topLevelAt', 'topLevelWidgets', 'type', 'wheelScrollLines', 'widgetAt', 'windowIcon']
>>> QApplication.initialize([])
Traceback (innermost last):
  File "<console>", line 1, in ?
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:616)

java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: Could not initialize class com.trolltech.qt.gui.QApplication

我尝试编译并运行一个简单的“Hello World”QtJambi示例,它运行正常。

我做错了什么想法?

由于

1 个答案:

答案 0 :(得分:2)

native libs!

我认为有一些共享库,也许java vm找不到它们。

有没有bin目录?它应该在路径上/而不是类路径!

查看how-to-add-native-library-to-java-library-path