How to solve error “ Exception in thread ”AWT-EventQueue-0“ java.lang.NullPointerException:”?

I made MyApp for arm processor(ARMv7, 512 RAM, Debian Wheezy OS, Openjdk-7 installed). When I run MyApp on this OS it gives error. My code and error are below. I search according that error but I can't solve that error. MyApp works fine on Pc which have installed Windows 7 and Ubuntu 12.04. So any one have idea or solution than suggest to me?

import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author JAY_2
 */
public class MyApp extends JPanel {

    /**
     * @param args the command line arguments
     */
    public static javax.swing.JTextField inpuText;
    private javax.swing.JLabel inputLbl;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel outPutLbl;
    public static javax.swing.JTextArea outPuttextArea;
    private javax.swing.JLabel tempLbl;
    public static javax.swing.JLabel tempShowLbl;
    public static javax.swing.JTextArea temptextArea;

    public MyApp() {
        // TODO code application logic here
        setComponents();
    }

    private void setComponents() {
        tempLbl = new javax.swing.JLabel("Temperature :");
        tempShowLbl = new javax.swing.JLabel("Label");
        inputLbl = new javax.swing.JLabel("InPut :");
        inpuText = new javax.swing.JTextField();
        outPutLbl = new javax.swing.JLabel("OutPut :");
        jScrollPane1 = new javax.swing.JScrollPane();
        outPuttextArea = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        temptextArea = new javax.swing.JTextArea(55000, 10);

        this.setBackground(new java.awt.Color(204, 255, 255));

        tempLbl.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N

        tempShowLbl.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N        

        inputLbl.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

        inpuText.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        inpuText.setText(""); // NOI18N

        outPutLbl.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

        outPuttextArea.setColumns(20);
        outPuttextArea.setRows(5);
        jScrollPane1.setViewportView(outPuttextArea);

        temptextArea.setColumns(20);
        temptextArea.setRows(10);
        jScrollPane2.setViewportView(temptextArea);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(this);
        this.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addComponent(inputLbl).addContainerGap(482, Short.MAX_VALUE)).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(outPutLbl).addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 102, Short.MAX_VALUE).addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)).addGroup(jPanel1Layout.createSequentialGroup().addComponent(inpuText, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 122, Short.MAX_VALUE).addComponent(tempLbl).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(tempShowLbl, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))).addGap(36, 36, 36)))));
        jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(inputLbl).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(inpuText, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(tempLbl, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(tempShowLbl, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addGap(43, 43, 43).addComponent(outPutLbl).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)).addGroup(jPanel1Layout.createSequentialGroup().addGap(3, 3, 3).addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE))).addContainerGap()));

    }

    public static void main(String[] args) {
        // TODO code application logic here
        JFrame jFrame = new JFrame();
        jFrame.add(new MyApp());
        jFrame.setSize(500, 400);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jFrame.setVisible(true);
    }
}

Error :

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: 
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.compareAndSetState(AbstractQueuedSynchronizer.java:566)
    at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:211)
    at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:290)
    at sun.awt.SunToolkit.flushPendingEvents(SunToolkit.java:551)
    at java.awt.EventQueue.postEvent(EventQueue.java:240)
    at sun.awt.PostEventQueue.flush(SunToolkit.java:2024)
    at sun.awt.SunToolkit.flushPendingEvents(SunToolkit.java:560)
    at java.awt.EventQueue.getNextEvent(EventQueue.java:523)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:180)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Exception in thread "AWT-XAWT" java.lang.NullPointerException: 
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.compareAndSetState(AbstractQueuedSynchronizer.java:566)
    at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:211)
    at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:290)
    at sun.awt.SunToolkit.awtLock(SunToolkit.java:237)
    at sun.awt.X11.XBaseWindow.ungrabInput(XBaseWindow.java:883)
    at sun.awt.X11.XToolkit.run(XToolkit.java:675)
    at sun.awt.X11.XToolkit.run(XToolkit.java:591)
    at java.lang.Thread.run(Thread.java:722)

Answers


Removed OpenJdk-7 version and install Oracle Jdk for ARM processor and Hard Float Os Image. Here is link for that.Oracle JDK for ARM processor


Retry this by executing your code in the EventDispatchThread :

public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                 JFrame jFrame = new JFrame();
                    jFrame.add(new MyApp());
                    jFrame.setSize(500, 400);
                    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    jFrame.setVisible(true);

            }
        });
    }

Need Your Help

How to use Android sensor event to determine if device is facing up or down

android rotation sensor

I have quite a simple requirement. Assuming a device is standing on its end, perpendicular to the ground, and it is tilted, all I need to determine is whether the phone is tilted forward or back (...

Creating Dynamic class and mapping file from existing class using Nhibernate

c# .net nhibernate nhibernate-mapping dynamic-class-creation

I want to create a new dynamic class with properties and mapping file from existing class and save it in the project then creating a dynamic table based on newly created property values and store i...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.