bonjour,
j'ai créé 3 fichiers, un nommé main, un nommé voiture et un nommé moteur
j'utilise intellij comme ide
main
voitureublic class Main {
public static void main(String[] args) {
Voiture maVoiture=new Voiture();
maVoiture.couleur="rouge";
maVoiture.nbDePorte=5;
Moteur monMoteur=new Moteur();
monMoteur.nbDeCylindre=5;
maVoiture.moteur=monMoteur;
System.out.println("le moteur a "+maVoiture.moteur.nbDeCylindre+ " cylindre ");
System.out.println("le moteur a "+monMoteur.nbDeCylindre+ " cylindre ");
System.out.println("Hello World!");
}
}
moteurpublic class Voiture {
int nbDePorte;
String couleur;
Moteur moteur;
}
public class Moteur {
int nbDeCylindre;
}
avec l'ide intellij je compile et j'exécute aucun problème
quand je passe en commande en ligne
je tape javac *.java ca marche
mais quand je tape java main
j'ai cette erreur
C:\Users\jm18c\IdeaProjects\helloword\src>java main
Error: Could not find or load main class main
Caused by: java.lang.NoClassDefFoundError: Main (wrong name: main)
je demande si c'est pas le fait d'avoir créer mon fichier contenant le void main, "main"
merci
Partager