Bonjour,

au moment de la compilation sous Netbeans de mon projet, je demande à écrire la date de compilation dans le fichier manifest grâce au fichier build.xml :
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
<?xml version="1.0" encoding="UTF-8"?>
<project name="MonProjet" default="default" basedir=".">
    <description>Builds, tests, and runs the project MonProjet.</description>
    <import file="nbproject/build-impl.xml"/>
    <tstamp>
        <!--<format property="compilationtime" pattern="dd.MM.yyyy_HH.mm.ss" />-->
        <format property="compilationtime" pattern="dd.MM.yy" />
    </tstamp>
    <manifest file="MANIFEST.MF">
        <attribute name="Version" value="${compilationtime}" />
        <attribute name="SplashScreen-Image" value="resources/logo.png" />
    </manifest>
</project>

Puis je lis le contenu de ce fichier manifest contenu dans le jar généré :
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
    private void getProjectVersion()
    {
        Manifest manifest;
        InputStream is;
        Attributes att;
        String info;
 
        try
        {
            is = this.getClass().getResourceAsStream("/META-INF/MANIFEST.MF");
            manifest = new Manifest(is);
 
            att = manifest.getMainAttributes();
            info = "Version : " + att.getValue("Version");
 
            this.jLabelVersion.setText(info);
            is.close();
        }
        catch (NullPointerException ex)
        {
            this.jLabelVersion.setText("Erreur");
        }
        catch (IOException ex)
        {
            this.jLabelVersion.setText("Erreur");
        }
    }
Ce code fonctionne sans problème sous Windows. Mais quand je compile sous Ubuntu (toujours avec Netbeans) att.getValue("Version") me retourne null. Aucune exception est levée.

Quel est le problème ?
J'ai vérifié le jar généré sous Ubuntu, la casse du dossier et du fichier est bien respectée.