Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to resolve "AWT-EventQueue-0" exception while running applet launched via JNLP
    text
    copied!<p>I am getting <code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException</code> while running applet launched via JNLP.</p> <p>My applet code is</p> <pre><code>package com.oprs.common; import java.awt.BorderLayout; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.net.MalformedURLException; import java.net.URL; import javax.jnlp.*; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import org.jfree.util.Log; /** * * @date Aug 29, 2012 11:33:16 AM * @version 1.0 */ public class OprsJNLP { /** * @param args */ static BasicService basicService = null; public static void main(String[] args) { JFrame frame = new JFrame("OPRS"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel(); Container content = frame.getContentPane(); content.add(label,BorderLayout.CENTER); String message = "Download OPRS Application"; label.setText(message); try { basicService = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService"); } catch (UnavailableServiceException e) { Log.error("service not available", e); } JButton button = new JButton("http://google.com/"); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { URL url; try { url = new URL(event.getActionCommand()); basicService.showDocument(url); } catch (MalformedURLException e) { e.printStackTrace(); } } }; button.addActionListener(listener); content.add(button, BorderLayout.SOUTH); frame.pack(); frame.show(); } } </code></pre> <p>I tried to debug and found that basicService is returning null always. In place of google.com i tried with the other url's but still getting the same error. The line <code>basicService.showDocument(url);</code> is where it throws null pointer because my basicService is null. Can some one point out where exactly i am going wrong ?</p> <p>Including my .jnlp</p> <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt; &lt;jnlp spec='1.0' codebase='http://localhost:9999/' href='oprs.jnlp'&gt; &lt;information&gt; &lt;title&gt;OPRS&lt;/title&gt; &lt;vendor&gt;OPRS&lt;/vendor&gt; &lt;description kind='one-line'&gt; OPRS WEB START &lt;/description&gt; &lt;shortcut online='false'&gt; &lt;desktop/&gt; &lt;/shortcut&gt; &lt;/information&gt; &lt;resources&gt; &lt;j2se version='1.4+' /&gt; &lt;jar href='oprs.jar' main='true' /&gt; &lt;/resources&gt; &lt;application-desc main-class='com.oprs.OprsJNLP' /&gt; &lt;/jnlp&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload