我有一个java应用程序,它在netbeans上运行得非常好并且作为独立运行,但是当我使用JNLP运行它时会出错。以下是日志的一部分:
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at texttospeech.MainPopup.buttonPlaySpeechActionPerformed(Unknown Source)
at texttospeech.MainPopup.access$100(Unknown Source)
at texttospeech.MainPopup$2.actionPerformed(Unknown Source)
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.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(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)
这是我的JNLP:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://localhost:8080" href="texttospeech.jnlp" version="1">
<information>
<title>Text To Speech</title>
<vendor>Interact</vendor>
<description>
Application to convert text to speech
</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.8+" href="http://java.sun.com/products/autodl/j2se"/>
<jar href="texttospeech.jar" main="true"/>
<jar href="/lib/freetts.jar"/>
<jar href="/lib/cmu_time_awb.jar"/>
<jar href="/lib/cmu_us_kal.jar"/>
<jar href="/lib/cmulex.jar"/>
<jar href="/lib/cmutimelex.jar"/>
<jar href="/lib/en_us.jar"/>
</resources>
<application-desc main-class="texttospeech.MainPopup"/>
<update check="background"/>
</jnlp>
在验证日志时,我发现正在下载所有JAR,并且没有任何问题。我的所有JAR都使用相同的证书签名(自签名)。我做了很多谷歌搜索 - 没有任何帮助。
技术细节
预期功能
MainPopup类加载 - 显示GUI。有一个按钮可以播放将输入的文本转换为语音并播放。它使用freeTTS。没有JNLP,此功能可以完美运行。
实际行为
当使用JNLP运行时,GUI会加载,并且MainPopup类的所有功能都可以运行。但是当我点击播放按钮(加载freeTTS VoiceManager)时,我得到了这个例外而我听不到任何声音。也许JNLP无法在其他JAR中找到类?
请帮我解决这个问题。如果您需要更多详细信息,请与我们联系。谢谢。