Error java awt

ANSWER: If you ever see these lines and are mistified like I was, here's what they mean. Thread[AWT-EventQueue-0] (Suspended (exception NullPointerException)) EventDispatchTread.run() line: not ava...

ANSWER:

If you ever see these lines and are mistified like I was, here’s what they mean.

Thread[AWT-EventQueue-0] (Suspended (exception NullPointerException))

EventDispatchTread.run() line: not available [local variables unavailable]

It’s not that the variables are unavailable because they are lurking behind a shroud of mystery in a library somewhere dank. No no, they just went out of scope! It’s still your fault, you still have to find the null, and no you can’t blame the library. Important lesson!

QUESTION:

One of the most frustrating things for me, as a beginner is libraries! It’s a love/hate relationship: On the one hand they let me do things I wouldn’t normally understand how to do with the code that I do understand, on the other hand because I don’t completely understand them, they sometimes throw a wrench in code that is otherwise working fine! It’s because I don’t understand the errors that can occur when using these libraries, because I didn’t write them, and because eclipse doesn’t give me a great deal to go with when one of imports starts acting up…

So here’s the problem: I’ve been working with java.awt.event to handle a bunch of JButtons on the screen for this and that. I get an error when I use one of the buttons I’ve made. The error is:

Thread[AWT-EventQueue-0] (Suspended (exception NullPointerException))

EventDispatchTread.run() line: not available [local variables unavailable]

What does this mean? What could be causing it? I’m embarrassed to post code, but if you can stand to try to decipher my terrible style, here is the method that seems to cause this error to be thrown.

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    String name;

code...

if(cmd.equals("Play")) {
        name = field.getText();
        card = getCard(name);
        
        if(card != null) {
            if(rules.zoneHasCard(card, rules.hand)) {
                display.updateStatusMessage(rules.play(card));
                field.setText("");
                display.updateHand(rules.zoneList("hand"));
                display.updateDiscard(rules.zoneList("Discard")); // This is the error here! The discard Zone was empty!
            }
            else {
                field.setText("You do not have " + card.getName());
                field.selectAll();
            }
        }
        else {
            field.setText("That cardname is unused");
            field.selectAll();
        }
    }
}

Issue

Since I’m new to java, I couldn’t figure out why this error occurred and how to resolve it.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Code;

import javax.swing.JTable;

/**
 *
 * @author Regan
 */
public class Report extends javax.swing.JFrame {

    /**
     * Creates new form Report
     */
    public Report() {
        initComponents();
       for(int i=0;i<Auditor.report.size();i++)
    System.out.println(Auditor.report.get(i));
        String column[]={"Fragment ID","Status"};  
        String[][] data=new String[Auditor.report.size()+1][2]; 
        data[0][0]="Fragment ID";
        data[0][1]="Status";
         for(int i=0;i<Auditor.report.size();i++)
            for(int j=0;j<Auditor.report.get(i).size();j++)
                data[i+1][j]=Auditor.report.get(i).get(j);
        JTable jt=new JTable(data,column);    
    jt.setBounds(30,40,200,300);
    jPanel1.add(jt);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Lucida Bright", 1, 36)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(169, 11, 63));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("AUDITING REPORT");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 500, 50));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 470, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 390, Short.MAX_VALUE)
        );

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, 470, 390));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Report.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Report.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Report.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Report.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Report().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
}

The above code causing the error but I’m still confused at whether it’s a IDE error or my code error. This error happens on both Visual Studio code and NetBeans

  1. What are the possible causes of a java.lang.Error: Unresolved compilation problem?
  2. Whether IDE is the only problem?

Traceback:

Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems: 
        org.netbeans cannot be resolved to a type
        org.netbeans cannot be resolved to a type
        org.netbeans cannot be resolved to a type

        at Code.Report.initComponents(Report.java:48)
        at Code.Report.<init>(Report.java:20)
        at Code.Report$1.run(Report.java:102)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:316)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Any kind of help is to be thankful

Solution

  1. What are the possible causes of a java.lang.Error: Unresolved compilation error problem?

This means you have a compilation error in your source code somewhere, and you have tried run the code without fixing the compilation error(s).

The error message in the exception is saying that there is an error in Code.Report class. Apparently, the code trying to use something in the org.netbeans package, but the compiler doesn’t know what that package is. I expect that the root cause is that a compile time project dependency is missing.

  1. Whether IDE is the only problem?

Not really. The probably root cause is that your project is not configured correctly, and YOU have ignored the compilation errors that the IDE indicated to you when you previously built the project.

  • The former can arises in different IDEs. Unless you configure the project dependencies correctly, the IDE cannot provide the correct classpath to the compiler.
  • That latter is your fault, not the IDE’s fault. You shouldn’t ignore compilation errors.

There is not enough context in your Question to say where the actual error is. But you should be able to locate it by doing a clean and build of the package and looking at the compilation errors that it reports.

Answered By — Stephen C
Answer Checked By — Willingham (JavaFixing Volunteer)

$ java -jar aprof-plot.jar
Exception in thread "main" java.awt.AWTError: Assistive Technology not found: org.GNOME.Accessibility.AtkWrapper
    at java.awt.Toolkit.loadAssistiveTechnologies(Toolkit.java:807)
    at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:886)
    at java.awt.Toolkit.getEventQueue(Toolkit.java:1734)
    at java.awt.EventQueue.invokeLater(EventQueue.java:1264)
    at aprofplot.Main.newWindow(Main.java:33)
    at aprofplot.Main.main(Main.java:359)

Possible explanations I saw here was to install Java-access-bridge. But I am unable to install libaccess-java-bridge.

serv-inc's user avatar

serv-inc

2,9211 gold badge23 silver badges29 bronze badges

asked Nov 8, 2015 at 18:40

Shiwangi Singh's user avatar

Shiwangi SinghShiwangi Singh

1,1112 gold badges8 silver badges4 bronze badges

I ran into this same error on my Ubuntu 15.10 server but did not want to install the non-headless version of OpenJDK due to the number of additional dependencies. A simpler solution was to simply disable assistive technologies.

This can be done by editing the accessibility.properties file for OpenJDK 8 (change the version to whichever is actually in use on your system):

sudo vim /etc/java-8-openjdk/accessibility.properties

Comment out the following line:

#assistive_technologies=org.GNOME.Accessibility.AtkWrapper

Also you can edit this line programmatically:

sudo sed -i -e '/^assistive_technologies=/s/^/#/' /etc/java-*-openjdk/accessibility.properties

David Foerster's user avatar

answered Jan 20, 2016 at 19:15

rdrever's user avatar

8

Read the following thread. I managed to escape this problem by uninstalling OpenJDK 8 headless and installing OpenJDK 8.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=798794

Commands I ran:

sudo dpkg -l | grep openjdk  

This is to verify you are actually running the headless version of JAVA, so no graph library available.

sudo apt-get remove openjdk-8-jre-headless

This is to remove headless version.

sudo apt-get install openjdk-8-jre

This is to install non-headless version of java.

answered Dec 2, 2015 at 17:17

danielmacho72's user avatar

2

For those who do not have root access on their machines to change the configuration file or do not want to install the full JRE: append -Djavax.accessibility.assistive_technologies=" " to your command, e.g.

$ java -jar aprof-plot.jar -Djavax.accessibility.assistive_technologies=" "

Do note that the " " is important, simply using «nothing» as parameter will cause the JRE to still load whatever is set in /etc/java-8-openjdk/accessibility.properties.

answered Jan 29, 2018 at 10:27

Marco Schuster's user avatar

2

Same issue. In my case I couldn’t run FastQC.
This is what I did:

$ sudo apt-get remove openjdk-11-jre-headless

I verified java was gone

$ java -version
bash: /usr/bin/java: No such file or directory
$ sudo apt-get install openjdk-8-jre

Problem solved.

abu_bua's user avatar

abu_bua

10.1k10 gold badges41 silver badges60 bronze badges

answered Sep 1, 2018 at 18:10

Max Medina's user avatar

Max MedinaMax Medina

711 silver badge2 bronze badges

0

I had to uninstall openjdk-11-jre, eg:

sudo apt remove openjdk-11-jre

or

sudo apt remove openjdk-11*

to remove all openjdk-11 packages on your system.

This forces your program to run on openjdk-8-jre instead of openjdk-11-jre, as I had both installed. Apparently Java Assistive Technology doesn’t run on the openjdk-11-jre package. I believe there is also a way to specify which Java version to run, but I don’t know it off the top of my head and I’m sure there’s another post on that topic.

answered Sep 1, 2018 at 15:47

4n0m4l0u5's user avatar

1

Inspired from Marco’s answer, but for me it only works in this order (prepending):

java -Djavax.accessibility.assistive_technologies=" " -jar aprof-plot.jar

It solved the problem and the program launched successfully (in my case argouml.jar fakesmtp.jar).

Using Java 8 on Ubuntu 2019.04

answered Apr 16, 2019 at 4:27

Nicolas Raoul's user avatar

Nicolas RaoulNicolas Raoul

11.2k25 gold badges90 silver badges148 bronze badges

This kind of error happens when you have a headless version of the JRE installed. The headless JRE is a subset of the full JRE but lacks GUI features, including support for assistive technologoes.

Install the full JRE (e.g. openjdk11-jre instead of openjdk11-jre-headless) and the error should go away. No need to uninstall the headless JRE.

answered May 11, 2020 at 16:51

user149408's user avatar

user149408user149408

1,3113 gold badges11 silver badges27 bronze badges

Все реализованные интерфейсы:
Serializable
public class AWTError extends Error

Выбрасывается,когда произошла серьезная ошибка Abstract Window Toolkit.

See Also:
  • Serialized Form

Constructor Summary

Constructor Description
AWTError(String msg)

Создает экземпляр AWTError с указанным подробным сообщением.

Method Summary

Методы, объявленные в классе java.lang. Метательный

addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString

Методы, объявленные в классе java.lang. Объект

clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Details

AWTError

public AWTError(String msg)

Создает экземпляр AWTError с указанным подробным сообщением.

Parameters:
msg — подробное сообщение.
Since:
1.0


OpenJDK

19

  • Field Summary

  • DstOut

  • Class AWTEvent

  • Class AWTEventMulticaster

Понравилась статья? Поделить с друзьями:
  • Error itoa was not declared in this scope
  • Error iterator should return strings not bytes did you open the file in text mode
  • Error it was not possible to connect hmailserver
  • Error issuing replication 8452 0x2104
  • Error iso image extraction failure