message d'avertissement "unchecked call"
Bonjour,
J'utilise le package JDOM comme decrit dans le tutoriel et je definis bien mon classpath.
voici ma classe :
Code:
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
| import java.io.*;
import java.util.*;
import org.jdom.*;
import org.jdom.output.*;
public class JavaToXml
{
public static QMatrix test;
public static Iterator it;
boolean b;
//Nous allons commencer notre arborescence en créant la racine XML
//qui sera ici "matrix".
static Element matrix = new Element("matrix");
//On crée un nouveau Document JDOM basé sur la racine que l'on vient de créer
static org.jdom.Document document = new Document(matrix);
public JavaToXml()
{
test=new QMatrix();
test.setInformations("Matrice de test");
test.setComments("commentaires");
test.getProperties().add("proprietes");
it=test.getProperties().iterator(); // ArrayList
}
static void affiche()
{
try
{
//On utilise ici un affichage classique avec getPrettyFormat()
XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
sortie.output(document, System.out);
}
catch (java.io.IOException e){}
}
static void enregistre(String fichier)
{
try
{
//On utilise ici un affichage classique avec getPrettyFormat()
XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
sortie.output(document, new FileOutputStream(fichier));
}
catch (java.io.IOException e){}
}
public static void main(String[] args)
{
String temp=new String();
//On cree un nouvel Element name et on l'ajoute
//en temps qu'Element de matrix
Element name = new Element("name");
name.setText(test.getName());
matrix.addContent(name);
//On cree un nouvel Element informations, on lui assigne du texte
//et on l'ajoute en temps qu'Element de matrix
Element informations = new Element("conformations");
informations.setText(test.getInformations());
matrix.addContent(informations);
//On cree un nouvel Element comments, on lui assigne du texte
//et on l'ajoute en temps qu'Element de matrix
Element comments = new Element("comments");
comments.setText(test.getComments());
matrix.addContent(comments);
//On cree un nouvel Element properties, on lui assigne du texte
//et on l'ajoute en temps qu'Element de matrix
Element properties = new Element("Properties");
while(it.hasNext())
temp+=(String)it.next()+" | ";
properties.setText(temp);
matrix.addContent(properties);
affiche();
enregistre("matrix1.xml");
}
} |
Lorsque je compile, j'obtiens ce message :
Citation:
JavaToXml.java:26: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
test.getProperties().add("propriete");
^
1 warning
Process completed.
A priori, pas de problemes puisque ce n'est "qu'un warning" il devrait au moins s'éxécuter.
Cependant lorsque j'éssaie d'éxécuter, voici ce qui m'est retourné dans le cmd :
Citation:
Exception in thread "main" java.lang.NoClassDefFoundError: JavaToXml
Press any key to continue...
Quelqu'un a-t-il une solution ?
Merci.