method <init> not found in class .

Status
Nicht offen für weitere Antworten.

tomxor

Neues Mitglied
Hi,
das soll ein Beispiel mit Threads in Java sein.

Code:
public class ThreadPrio extends Thread {
  String name;
  
  public ThreadPrio(String pName) {
    name = pName;
  }
  
  public void run() {
    for (int i=0; i<5; i++) {
      try {
        Thread.sleep(1000);
        System.out.println(name + " " + i);
      }
      catch(InterruptedException e) {}
    }
  }
}

Code:
public class Applikation2 extends Thread {
  public static void main(String args[]) {
    ThreadPrio t1 = new ThreadPrio();
    ThreadPrio t2 = new ThreadPrio();
    ThreadPrio t3 = new ThreadPrio();
    
    t1.setPriority(MIN_PRIORITY);
    t2.setPriority(NORM_PRIORITY);
    t3.setPriority(MAX_PRIORITY);
    
    t1.start();
    t2.start();
    t3.start();
  }
}

aber gibt Fehler in Applikation2:
- method <init> not found in class ThreadPrio

Ich arbeite mit JDeveloper 9.0.5.2. Bitte Hilfe!

tomxor.
 

Campino

Top Contributor
Den JDeveloper kenn zwar ich nicht, aber die Fehlermeldung nur von Applets...hast du deiner IDE erzählt, dass teil wäre eins? Ansonsten fehlt dir in der Applikation2 eine run()-Methode, sie erbt schließlich von Thread
 
G

Guest

Gast
In Deiner Klasse ThreadPrio gibt es keinen parameterlosen Konstruktor.
Der von Thread gilt nicht mehr, wenn Du Thread überschreibst.
 

Illuvatar

Top Contributor
Das kompiliert doch gar nicht, du kannst doch
Code:
ThreadPrio tn = new ThreadPrio();
nicht aufrufen wenn es keinen solchen Konstruktor gibt ???:L
 

tomxor

Neues Mitglied
ihr habt recht - ich hab' parameterlosen Konstruktor uebergeschrieben. Muss jetzt Parameter nutzen. Code soll so aussehen:

Code:
public class Applikation2 extends Thread {
  public static void main(String args[]) {
    ThreadPrio t1 = new ThreadPrio("t1");
    ThreadPrio t2 = new ThreadPrio("t2");
    ThreadPrio t3 = new ThreadPrio("t3");
    
    t1.setPriority(NORM_PRIORITY);
    t2.setPriority(MIN_PRIORITY);
    t3.setPriority(MAX_PRIORITY);
    
    t1.start();
    t2.start();
    t3.start();
  }
}

Thx for help!

tomxor.
 
Status
Nicht offen für weitere Antworten.
Ähnliche Java Themen
  Titel Forum Antworten Datum
R finaler Wert in outerMethod von method in InnerMethodClass Java Basics - Anfänger-Themen 2
S Methoden 2 non-static Methoden, trotzdem Fehler "non static method can not be referenced from a static context" Java Basics - Anfänger-Themen 9
P myClass?.method() in Java Java Basics - Anfänger-Themen 4
T setFill method Java Basics - Anfänger-Themen 3
H Methode mit Array als Rückgabe This method must return a result of Type int[] Java Basics - Anfänger-Themen 2
N The method setSaldo(double) in the type Konto is not applicable for the arguments (int, int) Java Basics - Anfänger-Themen 2
A startsWith method und substring Java Basics - Anfänger-Themen 2
W Remote Method Invocation RMI - Problem Java Basics - Anfänger-Themen 0
I Java Generics factory method Java Basics - Anfänger-Themen 2
V the static method should be accessed is a static way Java Basics - Anfänger-Themen 6
N Erste Schritte "non-static method" oder "XYZ can not be resolved" Java Basics - Anfänger-Themen 21
K Eigene Annotations, Pre-/Post-/Call-Method Java Basics - Anfänger-Themen 6
B Threads Thread sleep() Method einfache Frage Java Basics - Anfänger-Themen 8
G Was als main Method Java Basics - Anfänger-Themen 6
M Cannot make a static reference to the non-static method Java Basics - Anfänger-Themen 10
E Array to String Method Reverse Java Basics - Anfänger-Themen 5
D Methoden undefined method Java Basics - Anfänger-Themen 13
S Method mit Eingabe abrufen Java Basics - Anfänger-Themen 1
D Interface Amazon Skill Kit, Interface but method in other class? Java Basics - Anfänger-Themen 3
U Method References Java Basics - Anfänger-Themen 1
UnityFriday method getPrevious in class List<ContentType> cannot be applied to given types Java Basics - Anfänger-Themen 29
P Variablen einer Methode in andere Method übergeben Java Basics - Anfänger-Themen 6
B Methoden The method mirror(double[]) in the type Convolution is not applicable for the arguments (double) Java Basics - Anfänger-Themen 8
J easy remove method Java Basics - Anfänger-Themen 1
M abstract method does not override or implement.... Java Basics - Anfänger-Themen 7
R The method printf(String, Object[]) in the type printStrem in not applicable for the arguments ... Java Basics - Anfänger-Themen 3
M Deklaration und Initialisierung bei Method Erstellung Java Basics - Anfänger-Themen 12
K Variablen RETURN in Case-Switch / This method must return a result of type Item Java Basics - Anfänger-Themen 4
W Compiler-Fehler "non-static method cannot be referenced"-Problem Java Basics - Anfänger-Themen 6
K String equalIgnoreCase() Method Java Basics - Anfänger-Themen 19
E non-static method und static context Java Basics - Anfänger-Themen 15
L Command Prompt / Main Method / String Java Basics - Anfänger-Themen 9
M Methoden "Non-static method xy cannot be referenced from a static context" Java Basics - Anfänger-Themen 20
T selection method does not contain a main type Java Basics - Anfänger-Themen 7
U UML Factory Method Java Basics - Anfänger-Themen 4
R Compiler-Fehler Cannot find symbol (Method printIn) Java Basics - Anfänger-Themen 3
H non-static method cannot be referenced from a static context Java Basics - Anfänger-Themen 2
L Cannot make a static reference to the non-static method Java Basics - Anfänger-Themen 6
B Object "Method" in TreeSet, Fehler beim Vergleichen/Comparable Java Basics - Anfänger-Themen 9
M Problem mit Static Method Java Basics - Anfänger-Themen 8
W Main-method in Object-classes Java Basics - Anfänger-Themen 5
J Compiler findet method nicht Java Basics - Anfänger-Themen 12
M This method must return a result of type int Java Basics - Anfänger-Themen 13
M Fehlermeldung: the method.... ist undefined for the type object Java Basics - Anfänger-Themen 6
S this method must return a result of type double Java Basics - Anfänger-Themen 2
G Collections.binarySearch(LinkedList): cannot find method Java Basics - Anfänger-Themen 6
Y Theorie: Abstract Method Java Basics - Anfänger-Themen 6
C Methoden numberField.getDouble no such method error Java Basics - Anfänger-Themen 4
F Mal wieder: Cannot make a static reference to the non-static method Java Basics - Anfänger-Themen 9
F Cannot make a static reference to the non-static method Java Basics - Anfänger-Themen 3
Q non-static method blub cannot be referenced from a static context Java Basics - Anfänger-Themen 6
E Netbeans, "class does not have a main method" Java Basics - Anfänger-Themen 8
L no such method error: main() Java Basics - Anfänger-Themen 2
O Abstract Method & Generics Java Basics - Anfänger-Themen 10
N public class -> public method -> variable private? Java Basics - Anfänger-Themen 10
R Could not find main method Java Basics - Anfänger-Themen 3
U Boolean istGleich() Method Java Basics - Anfänger-Themen 15
Luk10 method () not found Java Basics - Anfänger-Themen 9
A OOP Fehler non-static method can not be[...] Java Basics - Anfänger-Themen 2
N Reference to non-static method Java Basics - Anfänger-Themen 8
G non static method scale(int,int) cannot be referenced from a static context Java Basics - Anfänger-Themen 16
A The method getYear() from the type Date is deprecated Java Basics - Anfänger-Themen 6
A cannot find symbol - symbol : method Java Basics - Anfänger-Themen 5
S The method readInt() Problem Java Basics - Anfänger-Themen 5
E method undefined - wo ist der Fehler? Java Basics - Anfänger-Themen 5
J non static method cannot be referenced from static context Java Basics - Anfänger-Themen 7
L cannot find symbol-method Java Basics - Anfänger-Themen 3
D kleine Passwortabfrage erstellen incl. Method zum verändern Java Basics - Anfänger-Themen 7
S Mein Quicksort Problem: he method quickSort(int[], int, int) Java Basics - Anfänger-Themen 2
M Invalid Method Java Basics - Anfänger-Themen 7
F does not overwride abstract method Java Basics - Anfänger-Themen 2
C Fehler: non-static method Java Basics - Anfänger-Themen 5
B method intValue() is undefined for the type String (?) Java Basics - Anfänger-Themen 4
R Cannot make a static reference to the non-static method Java Basics - Anfänger-Themen 5
G String zu Method Java Basics - Anfänger-Themen 11
B cannot find symbol method equalsIgnoreCase? Java Basics - Anfänger-Themen 23
T Does not have a main method ? GGT. Java Basics - Anfänger-Themen 4
N invalid method declaration; return type required Java Basics - Anfänger-Themen 4
T this method.is not visible Java Basics - Anfänger-Themen 3
C overridden method does not throw java.io.IOException Java Basics - Anfänger-Themen 4
R non-static method execute Java Basics - Anfänger-Themen 3
J Morgen Java-Klausur. Stack, Heap, Method-Area Java Basics - Anfänger-Themen 2
V Non Static Method. Java Basics - Anfänger-Themen 2
S Method undefinded for "Klasse" Java Basics - Anfänger-Themen 4
R Eclipse: This method must return a result of type double. Java Basics - Anfänger-Themen 2
M Fehlermeldung (The method contains(String) is. Java Basics - Anfänger-Themen 3
M Fehlermeldung (the method add(OE) in the type Abteilung.) Java Basics - Anfänger-Themen 2
N ActionListener versch. Buttons zuweisen => versch. Method Java Basics - Anfänger-Themen 13
G Problem (oder Verständnisporblem) bei einer static method Java Basics - Anfänger-Themen 9
frau-u Altes Problem: non-static method cannot be reference Java Basics - Anfänger-Themen 7
M Solaris - Method Split Fehler Java Basics - Anfänger-Themen 2
M method xxx() from the type xxx is deprecated Java Basics - Anfänger-Themen 3
A Method.invoke() mit geerbten Methoden Java Basics - Anfänger-Themen 2
A The method getClass() from the type saveLog is not static Java Basics - Anfänger-Themen 2
G Abstract Class - Abstract Method Java Basics - Anfänger-Themen 4
R Could not find Main-Method Java Basics - Anfänger-Themen 4
I No Jakarta Enterprise Beans found with interface ignorieren? Java Basics - Anfänger-Themen 2
I No EJB found with interface of type Java Basics - Anfänger-Themen 12
I Browser integriert in Desktop Applikation - Webcam interface not found Java Basics - Anfänger-Themen 26
C No suitable driver found for jdbc:odbc:mysql Java Basics - Anfänger-Themen 8

Ähnliche Java Themen

Neue Themen


Oben