Bonjour,

Alors mon problème est le suivant :

Je développe actuellement une application Swing et je souhaite pouvoir lancer l'ouverture d'un pdf inclut dans mon jar au clic sur une icone de mon interface graphique. Tout ce passe bien quand je test directement depuis Eclipse mais quand je lance le jar exécutable créé avec Eclipse et que je clic sur l'icone ouvrant le pdf, il me sort une exception :
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
 
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: The f
ile: file:\P:\Test\test.jar!\charteutilisationreseauwifi.pdf doesn't ex
ist.
        at java.awt.Desktop.checkFileValidation(Unknown Source)
        at java.awt.Desktop.open(Unknown Source)
        at presentation.AppliTicketWifiMainFrame.showCharteAction(AppliTicketWif
iMainFrame.java:619)
        at presentation.AppliTicketWifiMainFrame.mouseClicked(AppliTicketWifiMai
nFrame.java:525)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$000(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
Pour récupérer et ouvrir le pdf j'utilise ce 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
 
final String cheminCharte ="/charteutilisationreseauwifi.pdf";
 
		public void showCharteAction()
		{
			if(Desktop.isDesktopSupported())
			{		
				if(Desktop.getDesktop().isSupported(Desktop.Action.OPEN))
				{
					File pdf = new File(getClass().getResource(cheminCharte).getFile());
					try {
						Desktop.getDesktop().open(pdf);
					} catch (IOException e) {
						JOptionPane.showMessageDialog(null,"Erreur lors de la lecture de la charte :" + e.getMessage(),"Erreur", JOptionPane.ERROR);
					}
				}
			}
		}
Je précise que je suis allé vérifier à l'intérieur du jar et le fichier pdf y est bien présent.
Merci d'avance pour vos réponses car j'avoue ne pas comprendre l'erreur qui peut causer cette exception.