Mac: Netbeans & Eclipse Swing NullPointerException

havanna

Mitglied
Hi,

Ich arbeite unter Mac OSX und versuche gerade die JDK 1.7 in beiden IDE's zu verwenden, funktioniert auch bei beiden ohne Probleme in der IDE, aber sobalt ich ein JFrame in der mainmethode starten will bekomme ich immer eine NullPointerException. Bei Konsolenausgaben läuft alles super, nur beim anzeigen vom JFrame gibt es ne NullPointerException.

Hat jemand die selben Probleme oder liegt es nur an mir? ;)

Danke schonmal
Michael
 
T

Tomate_Salat

Gast
Wie immer ausgeschlossen wird, dass der eigene Code für eine NPE verantwortlich sein könnte :noe:
 

havanna

Mitglied
ja kann ausgeschlossen werden ;),

Code:
public class MitarbeiterFrame extends JFrame
{
public MitarbeiterFrame()
{
                super("Beispiel für Mitarbeiter");
		this.setBounds(100, 100, 300, 150);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		Container con = this.getContentPane();
}

public static void main(String[] args) 
	{
		MitarbeiterFrame fenster = new MitarbeiterFrame();
		fenster.setVisible(true);
	}
}

der code funktioniert ja auch mit der 1.6er Version vom Java JDK auf dem Mac nur nicht mit der 1.7er vom OpenJDK
 

havanna

Mitglied
So hier mal noch wie ich das gerade getestet habe:

Java:
package test;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.HeadlessException;
import javax.swing.JFrame;

/**
 *
 * @author havanna
 */
public class Test extends JFrame
{

    public Test() throws HeadlessException
    {
        super("Swing JFrame Test");
        
        this.setBounds(100, 100, 400, 300);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        
        Container con = this.getContentPane();
        con.setLayout(new BorderLayout());
    }

    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        new Test().setVisible(true);
    }
}
beim ausführen bekomme ich folgende Fehlermeldung:

Java:
Exception in thread "main" java.lang.NullPointerException
	at java.awt.Window.initGC(Window.java:464)
	at java.awt.Window.init(Window.java:484)
	at java.awt.Window.<init>(Window.java:533)
	at java.awt.Frame.<init>(Frame.java:418)
	at javax.swing.JFrame.<init>(JFrame.java:224)
	at test.Test.<init>(Test.java:21)
	at test.Test.main(Test.java:36)
Java Result: 1
ERSTELLEN ERFOLGREICH (Gesamtzeit: 0 Minuten 2 Sekunden)
 
T

Tomate_Salat

Gast
da gibt's "this" aber noch nicht so richtig.

Dann könnte das hier nur durch pure Magie funktionieren:
Java:
public class Sample {
    private String s;
    public Sample(String s)  {
        this.s=s;
    }
}

Nein, laut dem Stack müsste der Fehler in der Window.java liegen.
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
N Weder Eclipse noch Netbeans funktionieren auf Ubuntu 18.04 IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 0
pcfreak9000 Eclipse Netbeans generics IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
B IDE Netbeans und Eclipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
H Kann ich Commandline-Parameter in Eclipse oder Netbeans einfacher übergeben? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
MiMa Hin und her gerissen Netbeans und Eclipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
Guybrush Threepwood Jar-Export unter Netbeans (vs. Eclipse) IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
S Auto Complete in Eclipse wie bei Netbeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 9
D Eclipse Wie ein NetBeans-Projekt automatisch in Eclipse importieren? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
A Eclipse/NetBeans findet Java Installation auf Mac nicht! IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
J Netbeans to Eclipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 14
H NetBeans Von Eclipse nach Netbeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
G Eclipse/NetBeans package IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
Houly Eclipse Projekte in NetBeans öffnen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
S PASCAL-Plugin für Netbeans/Eclipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
J PDFBox und Lucene in Eclipse und Netbeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
F Source: Eclipse - > NetBeans und nichts geht mehr. IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
S Netbeans Projekt nach Eclipse migrieren IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
J Eclipse GUI in Netbeans verwendung und umgedreht IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
J Projektdaten tauschen Eclipse <--> NetBeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
T Nach Jahren mit Eclipse jetzt auch mal Netbeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
G Wie kann ich mir in Eclipse/NetBeans den ByteCode ansehen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
P Netbeans GUI in Eclipse importieren IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 9
G Ist es möglich: Netbeans und Eclipse + ein SVN-Server? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 9
G externe Library NetBeans / eclipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 12
W Eclipse Projekte in Netbeans 6.1 importieren? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
A set working directory - in Eclipse einfach - in NetBeans ? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
O Eclipse project in netbeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
A wie kann ich Netbeans Form Dateien in Eclipse benutzen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
W eclipse vs. NetBeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
M Eclipse oder Netbeans, automatisch Kommentar zufuegen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
J Einbinden von JAR Dateien in NetBeans und Eclipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
B Entwickeln auf OS X mit Eclipse und NetBeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
H Netbeans Eclipse blaues Aussehen bei Frames IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
B AppRun bei Eclipse und Netbeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 10
M NetBeans oder Eclipse? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
A Why Eclipse Developers Are Moving To NetBeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 26
G eclipse/netbeans - struts plugin IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
mi007 NetBeans / Eclipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
R Eclipse vs. Netbeans.. was ist besser? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 29
M Netbeans nutzt veraltete Bibliotheken für JAX-WS IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
W Debugger - Netbeans vs. VSCode IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
J Erstellen eines java Projekts mit Gradel in netbeans. IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 12
R Ist netbeans noch eine gute Wahl? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
mihe7 NetBeans 17 IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
MiMa Netbeans zu IntelliJ mit Maven konvertieren IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 14
I NetBeans 15 - Strg+Z (undo) und Strg+Y (redo) funzen nicht mehr nach Start der Java-Anwendung IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
J Netbeans 14 friert unter Linus Mint 21 prötzlich ein IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
mihe7 NetBeans NetBeans 16 ist da IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 0
M Altes Java Projekt in Netbeans importieren IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
MiMa Methoden in Netbeans vergleichen? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 23
M Linux Mint - Apache NetBeans 14 - Installationsanleitung deutsch IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
Neumi5694 Netbeans Warnung IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
T NetBeans NetBeans IDE 13 | Cannot find main class IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
J Seltsames Verhalten einer Klasse in netbeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
S License-Header in NetBeans 8.2 IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
G Netbeans 12.6 IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 9
kodela NetBeans App lässt sich ausßerhalb von NetBeans nicht ausführen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
J Netbeans - WakaTime - Plugin sendet keine Daten IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
J Netbeans - Werte von Variablen überwachen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
donnico2 Fehler beim Installieren von Apache Netbeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
J netbeans - refactoring funktioniert nicht mehr IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
S Netbeans unterstützung für "Rule Switch" - Bug? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
O NetBeans Netbeans 12.0 - Hintergrundfarbe, auch im Navigator und Projekt umstellen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
J Kombinationsproblem: netbeans, gradle, mysql, json IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
O NetBeans Netbeans 8.2 mit JKD 15 ? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
J Seltsames Verhalten von netbeans bezüglich fxml Dateien IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
J netbeans 12 - wie -Xlint:deprecation aktivieren IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
J Netbeans 11.1 - Gradel aktualisieren IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
E Suche aktuelle Netbeans-Version für Win 10 IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 30
B Netbeans: Java Script Libraries funktioniert nicht IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
J NetBeans Projekt erstellen nicht möglich IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
G eigene Library In NetBeans 11.1 IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
J Bekomme keine lauffähige jar (netbeans/gradle) IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 12
J Install JasperReports on netbeans/gradle Projekt IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
W NetBeans Umzug von Netbeans 8.2 -> Netbeans 11.1: Plug-Ins IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 7
F Umstieg von Netbeans 8 mit JDK 8 auf Apache Netbeans 11 mit OpenJDK 12 IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
MiMa JavaFX in Netbeans 11 installieren? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 32
G NetBeans Netbeans 8.2 hängt sich auf IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 15
W Netbeans and Git Projects IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
J NetBeans Dokumentation anderer Projekte IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
J NetBeans Download NetBeans und Java SDK IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
MiMa compile with -Xlint bei Netbeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
C Netbeans Meldung: Git Push Failed IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
TheJavaKid NetBeans JDBC Library mit Netbeans in Jarfile mit packen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 13
J Netbeans: Einsicht in den Programmlauf IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
J NetBeans Notizen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
C maven startet jetty, netbeans "run" startet glassfish IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
L NetBeans NetBeans autofill einrichten IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
K Netbeans + Maven: default pom Inhalt IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
M Netbeans CSS code completion abgeschaltet IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
TomatenBrot447 Netbeans ziegt mir falsche Tasteneingabe an IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
wolfgang63 Netbeans 8.2 ohne Projektvorlagen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
MiMa Ist Netbeans mist ??? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 14
K easy UML Plugin Netbeans 8.1 IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
WetWer NetBeans Wird NetBeans eigentlich noch unterstützt? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
F Netbeans Overriden - @ IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
Tort-E NetBeans Netbeans RCP Spracheinstellungen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
M Netbeans GUI Builder größe ändern IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 0
Y Tomcat aus Netbeans heraus starten schlägt fehl IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
A Login-Programmierung mit NetBeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 7

Ähnliche Java Themen

Neue Themen


Oben