Eclipse Debuggen ohne main()-Methode

Criz29

Mitglied
Hallo zusammen,

wie kann man z.B. folgenden Code debuggen? Der hat zwar keine Fehler i.d.S., möchte es aber trotzdem überprüfen können.

Java:
public class Wein {
    private int alter;
    private double grundpreis;
    private double preisProFlasche;
    
    
    public Wein() {
        this(1, 10);
    }
    
    public Wein(int alter) {
        this(alter, 10);
    }
    
    public Wein(double grundpreis) {
        this(1, grundpreis);
    }
    
    public Wein(int alter, double grundpreis) {
        if (alter > 0)
            this.alter = alter;
        else
            this.alter = 1;
        if (grundpreis > 9)
            this.grundpreis = grundpreis;
        else
            this.grundpreis = 10;
    }
    
    public void preisBerechnen() {
        preisProFlasche = alter * grundpreis;
    }
    
    public double getPreisProFlasche() {
        preisBerechnen();
        return preisProFlasche;
    }
}


Also, über Debugging Konfiguration kann ich das entsprechende Projekt und die Hauptklasse auswählen bzw. eingeben. Dann kriege ich nur immer eine Fehlermeldung:

Fehler: Hauptmethode in Klasse projektname.Wein nicht gefunden. Definieren Sie die Hauptmethode als:
public static void main(String[] args):
oder eine JavaFX-Anwendung muss javafx.application.Application erweitern
 

KonradN

Super-Moderator
Mitarbeiter
Also der Debugger muss ja irgend etwas ausführen und das ist bei Java erst einmal per default die main Methode.

Statt aber eine eigene main Methode zu erstellen, kannst du Frameworks nutzen, die dann eine eigene Main Methode haben. Ein typisches solches Framework ist JUnit. Du hast dann sogenannte Unit Tests, die schreibst und gestartet wird dann sozusagen ein Test Ausführer, der dann die Unit Tests ausführt.
Und die Ausführung der Tests kann man dann auch debugger.

Also in kurz: Schau dir mal Unit Tests an.
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
J Eclipse Debuggen ohne Haltepunkt?? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 7
K In Java11 JDK Klase überschreiben (Debuggen bzw. erweitern) IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
W NetBeans Netbens - Unittest debuggen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 18
B IDEA IntelliJ Gradle Projekt debuggen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
J Eclipse WebApplication debuggen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
G Eclipse Debuggen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
Ebenius JComboBox unter Linux debuggen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
D debuggen in eclipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
T Eclipse, Tomcat: 1 Mal debuggen möglich IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
T Netbeans PHP Debuggen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
M Dynamischer Typ beim Debuggen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
D Testen und debuggen gleichzeitig mit NetBeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
W Firewalleinstellungen, um mit Eclipse debuggen zu können? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
G SUN JDK Quellcode zum Debuggen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
H Servlet in Eclipse debuggen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
G Eclipse debuggen seeehr langsam IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 12
M Debuggen mit eclipse. IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 7
N Debuggen in Eclipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
S Debuggen im JRE-Code IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
H Eclipse Debugging: GUI-Prog debuggen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
B NetBeans - Einzelne Klasse debuggen? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
S debuggen von MouseListener IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
T Eclipse? Debuggen ? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
Kartoffel_1 ohne "package ch1" runs. IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
F Eclipse - Änderung am Code ohne Applikation Neustart IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
B Eclipse version control System das ohne Internet funktioniert/nur lokal auf Computer? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
O NetBeans Java Projekt OHNE Maven erstellen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
O NetBeans Java Projekt OHNE Maven IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 0
B Kompilieren in Eclipse ( 2 Klasse ohne main()-Methode) IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 7
M Intellij IDEA Programm ohne Main-Methode starten IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
T .project Datei im Explorer ohne Namen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
it_is_all NetBeans Clean and Build Project - Buttons ohne Funktion bei jar-Datei IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 22
M Eclipse JavaFX ohne e(fx)clipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
wolfgang63 Netbeans 8.2 ohne Projektvorlagen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
A in netbeans 8 mit jdk 8 erstellte jar's laufen nicht auf anderen rechnern ohne jdk IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
P Java ohne IDE IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 15
I Eclipse, Ausklappen mit Stern, aber ohne Outline der Klassen? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
B Welche IDE, die GUIs gestalten kann, ohne externe Lagerung? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
S NetBeans Serializable Class ohne package IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
M Eclipse Diverse Errors ohne Grund IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
fastjack EMMA ohne AllTests IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
M Eclipseprojekte (Java) ohne Eclipse ausführen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
ARadauer Ganymede ohne JSP Editor IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
M Eclipse: Ausführen eines Programmes ohne Ant möglich? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 10
D Projekt ohne Komplikationen in Eclipse importieren IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
T Subversion ohne Repository (Server) IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
reibi Eclipse - Classfiles ohne Source werden automatisch gelöscht IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
J Programmieren mit Eclipse ohne Javadownload? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 14
ARadauer eclipse compiliert ohne jdk IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
F eclipse rcp ohne pluginsystem, also nur die gui davon? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
André Uhres Quellcode mit SWT ohne Eclipse kompilieren IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
T Eclipse Git "Could not find or load main class" IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
T NetBeans NetBeans IDE 13 | Cannot find main class IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
W Eclipse Rechnerabsturz - Datei der Main zerstört? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 15
B Fehlermeldung: Selection does not contain a main type IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
T Eclipse - Keine Vorschläge außerhalb main-Methode IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 9
J Error: Could not find or load main class xyz (Eclipse) IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 7
wolfgang63 Eclipse findet main-methode nicht IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
N [ANT] Invalid signature file digest for Manifest main attributes IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
S Findet 'main' in Eclipse nicht IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
K Eclipse automatische main Klasse - Formatierung ändern ? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
E Eclipse Jar-File [,,Could not find the main class - program will exit"] IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 25
H NETBEANS 7.0 - Run findet kein main() IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
S JBuilder [ANT] Anfängerfragen zu ANT und der main class IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
H diverse IDEs: main-class nicht gefunden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
J Main Methode in Netbeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
N NetBeans "main class not found" in NetBeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 17
B Eclipse: Could not find the main Class IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 15
T NB6.5: Fehler beim ausführen einer (Main)Klasse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
S NetBeans; Anfängerfragen.insbesondere zur Main - Class IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
E could not fin d the main class. program will now exit IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 14
F Selection does not contain a main type IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
M mal wieder Could not finde the main class.Program will exit IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
B Netbeans Run main() mit args IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
G parameter an main übergeben in eclipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2

Ähnliche Java Themen

Neue Themen


Oben