У меня проблемы с некоторыми кодами, и я действительно не могу устранить эту ошибку.
Я использую Interprolog (Java + Prolog), см. здесь
вот трассировка стека:
Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(Unknown Source)
at com.declarativa.interprolog.AbstractPrologEngine.copyToTemp(AbstractPrologEngine.java)
at com.declarativa.interprolog.AbstractPrologEngine.consultFromPackage(AbstractPrologEngine.java)
at LoginHandler.actionPerformed(LoginHandler.java:24)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
и соответствующий код:
myEngine = new NativeEngine();
myEngine.consultFromPackage("C:\\interprolog212a\\userlist.p", LoginHandler.class);
boolean x = myEngine.deterministicGoal("hasAccess(user,pass)");
есть идеи? Я бью кирпичную стену ...
о, а строка 24 - вторая строка кода, которую я разместил.
edit: содержимое userlist.p:
hasAccess(tom,123).
hasAccess(bob,456).
Исходя из некоторых предложений ниже, я переместил loginhandler и связанные с ним классы в их собственный пакет, а также userlist.p в пакет, и теперь я получаю эту ошибку:
com.declarativa.interprolog.util.IPException: Problem consulting from package archive:C:\Users\Keval\AppData\Local\Temp\IP_5283895338735856757\userlist.p