IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage Java Discussion :

erreur java : "java.lang.NoClassDefFoundError: java"


Sujet :

Langage Java

  1. #1
    Membre du Club Avatar de Emilie MARQUOIS-OGEZ
    Femme Profil pro
    Inscrit en
    Septembre 2005
    Messages
    80
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2005
    Messages : 80
    Points : 42
    Points
    42
    Par défaut erreur java : "java.lang.NoClassDefFoundError: java"
    Bonjour,

    Quand je lance mon programme sous Eclipse, j'ai l'erreur suivante dans ma console :

    java.lang.NoClassDefFoundError: java
    Exception in thread "main"

    Pourtant ma méthode "main" est au bon endroit. Dans l'API Java, cette erreur renvoie à la question de la définition de la classe.

    "Thrown if the Java Virtual Machine or a ClassLoader instance tries to load
    in the definition of a class (as part of a normal method call or as part of
    creating a new instance using the new expression) and no definition of the
    class could be found."

    Merci d'avance pour votre aide.

    Emilie

    PS : désolée de ne pas mettre les balises mais je n'ai pas réussi à les faire fonctionner.

  2. #2
    Membre émérite
    Avatar de mavina
    Homme Profil pro
    Développeur Java
    Inscrit en
    Octobre 2004
    Messages
    1 812
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Chine

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Conseil

    Informations forums :
    Inscription : Octobre 2004
    Messages : 1 812
    Points : 2 411
    Points
    2 411
    Par défaut
    Salut,

    Pourrais-tu nous mettre tout le code de la classe contenant le main ?

    Merci

    Fred
    Développeur Java / Flex à Shanghai, Chine
    mes publications
    Mon dernier tutoriel : Messages Quit IRC : explications

    La rubrique IRC recrute des redacteurs : contactez moi

    Ce flim n'est pas un flim sur le cyclimse. Merci de votre compréhension.[/SIZE]

  3. #3
    Membre du Club Avatar de Emilie MARQUOIS-OGEZ
    Femme Profil pro
    Inscrit en
    Septembre 2005
    Messages
    80
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2005
    Messages : 80
    Points : 42
    Points
    42
    Par défaut
    Voili le code.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    package launch;
     
    import java.io.RandomAccessFile;
    import java.util.Iterator;
    import java.util.TreeMap;
    import java.util.Vector;
     
    public class GenerateExperimentations {
     
    	public GenerateExperimentations() {
    	}
     
    	public static void createFiles() {
     
    		RandomAccessFile f, fa, fb, fc, fstats, fd, fe, ff, fg, fh, fi;
     
    		int[] popInit = { 200 };
    		float[] levelSalience = { 0.1F, 0.2F, 0.3F, 0.4F, 0.5F, 0.6F, 0.7F, 0.8F, 0.9F, 1.0F };
     
    		try {
    			// MembersObserver a = new SimpleObserver("./events.txt");
    			// observer qui ecrit dans un fichier ce que chaque membre fait
    			// Member.addMembersObserver(a);
     
    			f = new RandomAccessFile("/Documents and Settings/emie/Mes documents/socRepK2" + "_LISTE_nbMessForThemes.txt", "rw");
    			f.writeBytes("\r\n\r\npopInit\tlevelSalience\tnbIter\tnbMessTotal\tnbMessInit\tnbMessRep\r\n\r\n");
    			fa = new RandomAccessFile("/Documents and Settings/emie/Mes documents/socRepK2" + "_LISTE_nbMessForThemesAndThreads.txt", "rw");
    			fb = new RandomAccessFile("/Documents and Settings/emie/Mes documents/socRepK2" + "_LISTE_nbThreadsForThemes.txt", "rw");
    			fc = new RandomAccessFile("/Documents and Settings/emie/Mes documents/socRepK2" + "_LISTE_messAndLevelKforThemesAndThreads.txt", "rw");
    			fd = new RandomAccessFile("/Documents and Settings/emie/Mes documents/socRepK2" + "_MB_evolLevelKforThemes.txt", "rw");
    			fe = new RandomAccessFile("/Documents and Settings/emie/Mes documents/socRepK2" + "_LISTE_messAndAuthorsForThemesAndThreads.txt", "rw");
    			ff = new RandomAccessFile("/Documents and Settings/emie/Mes documents/socRepK2" + "_MB_nbMessForThemes.txt", "rw");
    			fg = new RandomAccessFile("/Documents and Settings/emie/Mes documents/socRepK2" + "_LISTE_moyLevelKforThemes.txt", "rw");
    			fh = new RandomAccessFile("/Documents and Settings/emie/Mes documents/socRepK2" + "_MB_evolLevelRepKforThemes(mbEvalue).txt", "rw");
    			fi = new RandomAccessFile("/Documents and Settings/emie/Mes documents/socRepK2" + "_MB_evolLevelRepKforThemes(mbEstEvalue).txt", "rw");
    			fstats = new RandomAccessFile("/Documents and Settings/emie/Mes documents/socRepK2" + "_LISTE_nbThreadsWithNbMessForThemes.txt", "rw");
     
    			Member.compteur = 0;
    			for (int j = 0; j < popInit.length; j++) {
    				for (int l = 0; l < levelSalience.length; l++) {
    					for (int i = 0; i < 1; i++) {
    						Member.compteur = 0;
    						SimVirtCom svc = new SimVirtCom(popInit[j],levelSalience[l]);
    						ObservationSimu obsSimu = svc.getObsSimu();
     
    						System.out.println();
    						System.out.println("** OBSERVATION SIMU **");
    						System.out.println();
     
    						f.writeBytes(obsSimu.popInitLevelSalience(popInit[j], levelSalience[l]));
    						f.writeBytes(obsSimu.getListeNbMessThemes());
    						System.out.println("f fin");
    						fa.writeBytes(obsSimu.getListeNbMessForThemesAndThreads(popInit[j], levelSalience[l]));
    						System.out.println("fa fin");
    						fb.writeBytes(obsSimu.getListeNbThreadsForThemes(popInit[j], levelSalience[l]));
    						System.out.println("fb fin");
    						fc.writeBytes(obsSimu.getListeMessAndLevelKForThemesAndThreads(popInit[j], levelSalience[l]));
    						System.out.println("fc fin");
    						fd.writeBytes(obsSimu.getMemberEvolLevelKforThemes(popInit[j], levelSalience[l]));			
    						System.out.println("fd fin");
    						fe.writeBytes(obsSimu.getListeMessAndAuthorForThemesAndThreads(popInit[j], levelSalience[l]));
    						System.out.println("fe fin");
    						ff.writeBytes(obsSimu.getMemberNbMessForThemes(popInit[j], levelSalience[l]));
    						System.out.println("ff fin");
    						fg.writeBytes(obsSimu.getListeMoyLevelKForThemes(popInit[j], levelSalience[l]));
    						System.out.println("fg fin");
     
    						fh.writeBytes(obsSimu.getMemberEvolLevelRepKforThemes1(popInit[j], levelSalience[l]));
    						System.out.println("fh fin");
    						fi.writeBytes(obsSimu.getMemberEvolLevelRepKforThemes2(popInit[j], levelSalience[l]));
    						System.out.println("fi fin");
    					}
    				}
    			}
    			f.close();			
    			fa.close();
    			fb.close();
    			fc.close();
    			fd.close();
    			fe.close();
    			ff.close();
    			fg.close();
    			fh.close();
    			fi.close();
     
    			// ce qui sera consigne dans le fichier fstats de GenerateExperimentations
    			// Nombre de threads ayant 2 messages, 3 messages...
    			String ligne;
    			String[] splits;
    			Integer nb = new Integer(0);
    			Vector listeLevelS = new Vector();
    			RandomAccessFile fa2 = new RandomAccessFile("/Documents and Settings/emie/Mes documents/socRepK2" + "_LISTE_nbMessForThemesAndThreads.txt.txt", "rw");
     
    			while ((ligne = fa2.readLine()) != null) {
    				splits = ligne.split("\t");
    				if (splits.length == 5) {
    					try {
    						Integer.parseInt(splits[3]);
    						nb = new Integer(Integer.parseInt(splits[4]));
    						TreeMap statsLevelS=(TreeMap) listeLevelS.lastElement();
    						if (statsLevelS.containsKey(nb)){
    							Integer value = (Integer) statsLevelS.get(nb);
    							value=new Integer(value.intValue() + 1);
    							statsLevelS.put(nb, value);
    						}
    						else {
    							statsLevelS.put(nb, new Integer(1));
    						}
     
    					} catch (NumberFormatException e) {
    						listeLevelS.add(new TreeMap());
    					  }
    				}
    			}
     
    			int indexSalience=0;
    			for (int b = 0; b < listeLevelS.size(); b++) {
    				TreeMap statsLevelS = (TreeMap) listeLevelS.get(b);
    				fstats.writeBytes("\nlevelSalience="+levelSalience[indexSalience]+"\n");				
    				Iterator it = statsLevelS.keySet().iterator();
    				while (it.hasNext()) {
    					Integer tmp1 = (Integer) it.next();
    					fstats.writeBytes(tmp1+" messages"+ " Nb="+statsLevelS.get(tmp1)+"\n");
    				}
    				indexSalience++;
    			}
    			fstats.close();	
    			System.out.println("fstats fin");
     
    		} catch (Exception e) {
    			System.err.println("error " + e.getMessage());
    			e.printStackTrace();
    		  }
    	}
     
    	public static void main(String[] args) {
    		createFiles();
    		Runtime runtime = Runtime.getRuntime();
    		System.out.print( "used : " + ( runtime.totalMemory()-runtime.freeMemory()));
    		System.out.print( " committed : " + runtime.totalMemory());
    		System.out.println( " max : " + runtime.maxMemory());
    		System.out.println("FIN");
    	}
    }

  4. #4
    Membre expérimenté
    Avatar de zekey
    Profil pro
    Inscrit en
    Février 2005
    Messages
    1 036
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 1 036
    Points : 1 403
    Points
    1 403
    Par défaut
    Ce n'est pas la méthode main le problème mais une classe dont tu as besoin.
    Peux tu nous communiquer la stack trace complète ?
    Steve Hostettler
    est ton ami(e) et le tag aussi.

  5. #5
    Membre éprouvé
    Profil pro
    Architecte technique
    Inscrit en
    Mars 2002
    Messages
    966
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France

    Informations professionnelles :
    Activité : Architecte technique

    Informations forums :
    Inscription : Mars 2002
    Messages : 966
    Points : 1 085
    Points
    1 085
    Par défaut
    Par contre si je peux me permettre ton code est tout laid.

    A savoir:

    - pourquoi ne pas utiliser un tableau de RandomAccessFile au lieu de 11 variables ?

    - pourquoi trois boucles imbriquées ???

    - Et les close() ça se fait dans un finally

    A+

  6. #6
    Membre du Club Avatar de Emilie MARQUOIS-OGEZ
    Femme Profil pro
    Inscrit en
    Septembre 2005
    Messages
    80
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2005
    Messages : 80
    Points : 42
    Points
    42
    Par défaut
    C'est quoi la stack trace complète et comment je le recupère ?

  7. #7
    Expert éminent sénior
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Points : 12 977
    Points
    12 977
    Par défaut
    Grosso modo il te demande toute les erreurs qui apparaissent sur la console quand ton exception est levée.

    Sinon pour ton problème, as tu bien mis en place le classpath? (cad utiliser l'option -cp .;chemin/Vers/Jar/1;chemin/Vers/Jar/2 sous windows et .:chemin/Vers/Jar/1:chemin/Vers/Jar/2 sous *NIX)
    Hey, this is mine. That's mine. All this is mine. I'm claiming all this as mine. Except that bit. I don't want that bit. But all the rest of this is mine. Hey, this has been a really good day. I've eaten five times, I've slept six times, and I've made a lot of things mine. Tomorrow, I'm gonna see if I can't have sex with something.

  8. #8
    Membre du Club Avatar de Emilie MARQUOIS-OGEZ
    Femme Profil pro
    Inscrit en
    Septembre 2005
    Messages
    80
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2005
    Messages : 80
    Points : 42
    Points
    42
    Par défaut
    Je suis sous Eclipse, le classpath a été configuré automatiquement, non ? Par ailleurs, sous Eclipse, lorsque je lance d'autres programmes, je ne rencontre aucun problème.

    Sinon, en ce concerne les erreurs, je n'ai rien de plus dans la console que ce j'ai donné dans mon premier message, à savoir :

    java.lang.NoClassDefFoundError: java
    Exception in thread "main"

  9. #9
    Expert éminent sénior
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Points : 12 977
    Points
    12 977
    Par défaut
    Ton programme ne dépendrait il pas d'un autre projet ou d'un jar spécifique?
    Hey, this is mine. That's mine. All this is mine. I'm claiming all this as mine. Except that bit. I don't want that bit. But all the rest of this is mine. Hey, this has been a really good day. I've eaten five times, I've slept six times, and I've made a lot of things mine. Tomorrow, I'm gonna see if I can't have sex with something.

  10. #10
    Membre du Club Avatar de Emilie MARQUOIS-OGEZ
    Femme Profil pro
    Inscrit en
    Septembre 2005
    Messages
    80
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2005
    Messages : 80
    Points : 42
    Points
    42
    Par défaut
    Non. C'est bizarre que ça fonctionne pas alors que pour les autres ça fonctionne.
    J'ai fait, dernièrement, un copier-coller des fichiers (jave + class) que j'ai fait au boulot dans mon workspace sur mon ordi perso. Ca pourrait venir de là ?

  11. #11
    in
    in est déconnecté
    Membre expérimenté Avatar de in
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    1 612
    Détails du profil
    Informations personnelles :
    Localisation : France, Finistère (Bretagne)

    Informations forums :
    Inscription : Avril 2003
    Messages : 1 612
    Points : 1 718
    Points
    1 718
    Par défaut
    tu as recompilé chez toi ? -> Efface tes .class et refait le build.

    Il doit te manquer une librairie je pense, mais comme tu as déjà les .class, ce n'est qu'à l'exécution que ça plante ...
    "If email had been around before the telephone was invented, people would have said, 'Hey, forget email! With this new telephone invention I can actually talk to people!"

    Besoin d'une nouvelle méthode pour développer ? -> http://www.la-rache.com/

Discussions similaires

  1. Erreur d'exécution de type java.lang.NoClassDefFoundError
    Par lelorf1983 dans le forum JDeveloper
    Réponses: 3
    Dernier message: 01/06/2007, 15h20
  2. Réponses: 13
    Dernier message: 31/01/2007, 23h22
  3. Réponses: 9
    Dernier message: 08/10/2006, 15h30
  4. Réponses: 2
    Dernier message: 30/06/2006, 15h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo