witam,
pisze program w javie eclipse, podczas uruchamiania programu wyskakuje mi blad Could not find or load main class Main,
jak to naprawić
uruchom z klasy głównej która ma metodę main albo nie masz metody main.
uruchamiam z klasy głównej i dalej mam ten sam błąd
import java.util.List;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
Greetings();
Elephant elephant = new Elephant("Baniamin", 3);
Elephant john = new Elephant("John", 101);
Tiger killer = new Tiger("Killer");
killer.Roar();
List<Animal> listOfAnimals = new ArrayList<Animal>();
listOfAnimals.add(elephant);
listOfAnimals.add(john);
listOfAnimals.add(killer);
System.out.println("\nList of my animals");
for (Animal animal : listOfAnimals) {
System.out.println(" - "+animal.getName());
}
}
public static void Greetings(){
System.out.println("|========================|");
System.out.println("|===Name: ens26 - DW===|");
System.out.println("|===Project: Zadanie 1.==|");
System.out.println("|===Date: 27.12.2014=====|");
System.out.println("|========================|");
System.out.println("");
}
}
A nie masz przypadkiem w nazwie projektu przecinka, dwukropka albo czegoś takiego?
w którymś JDK był z tym problem.
Kod jest OK. Nie mam Eclipse pod ręką, ale w górnym menu powinno być Project>Clean Project. Eclipse już tak ma, że nie łapie niektórych zmian
niemam nic takiego
dalem clean project teraz wyskakujemi blad selection does not contain a main type podczas uruchamiania
prawy przycisk myszy na Twoją klasę Main->Run as->Java Application i ciągle się wywala?
tak ciągle wywala
ściągnij intellij Idea communiti edition i zaimportuj projekt ;-)
https://www.jetbrains.com/idea/download/
zaimportowalem projekt intellij Idea communiti edition wyskakuje błąd Cannot start compiler:the sdk is not specified for the
module'Zadanie1' Specify the sdk at project structure dialog
Jeśli nie znasz angielskiego to nie bierz się za javę, bo zginiesz, a jeśli znasz to zrób to co mówi Ci komunikat: wprowadź ścieżkę do SDK w "Project structure" (jest w "File").