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 :

Lancer l'exécution d'Acrobat Reader


Sujet :

Langage Java

  1. #1
    Membre éprouvé
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    907
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 907
    Par défaut Lancer l'exécution d'Acrobat Reader
    Bonjour,

    Comment lancer l'exécution de Acrobat Reader à partir d'un programme Java. Avec comme paramètre le nom du fichier pdf à ouvrir.

    Merci,
    Christophe,

  2. #2
    Expert éminent
    Avatar de adiGuba
    Homme Profil pro
    Développeur Java/Web
    Inscrit en
    Avril 2002
    Messages
    13 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java/Web
    Secteur : Transports

    Informations forums :
    Inscription : Avril 2002
    Messages : 13 938
    Billets dans le blog
    1
    Par défaut
    Salut,


    Regarde du coté de l'API JDIC... cela a été traité plusieurs fois sur le forum...

    a++

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    38
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations forums :
    Inscription : Janvier 2004
    Messages : 38
    Par défaut
    Essaie
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Runtime.getRuntime().exec("tonCheminAcrobatReader.exe tonfichier.pdf" );

  4. #4
    Membre éprouvé
    Avatar de Deadpool
    Homme Profil pro
    Inscrit en
    Novembre 2005
    Messages
    1 312
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations forums :
    Inscription : Novembre 2005
    Messages : 1 312
    Par défaut
    Citation Envoyé par Tangi29
    Essaie
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Runtime.getRuntime().exec("tonCheminAcrobatReader.exe tonfichier.pdf" );
    La solution JDIC préconisée par adiGuba est préférable car plus propre et plus portable.

    En plus le code est plus simple :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Desktop.open(new File("le chemin du fichier que tu veux ouvrir"));
    Le plus fort c'est que ça marche avec n'importe quel type de fichier pour peu qu'un programme soit associé avec ce type.

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    147
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Septembre 2006
    Messages : 147
    Par défaut
    Je dois vraiment avoir de la peine, mais comment fait-on peur donner le chemin relatif ? Le fichier est dans mon package.

    J'ai essayé:
    Runtime.getRuntime().exec("fichier.html");
    --> java.io.IOException: CreateProcess: fichier.html error=2

    Runtime.getRuntime().exec("./fichier.html");
    --> java.io.IOException: CreateProcess: .\fichier.html error=2

    Runtime.getRuntime().exec("dossier/fichier.html");
    --> java.io.IOException: CreateProcess: dossier\fichier.html error=193

    Runtime.getRuntime().exec("./dossier/fichier.html");
    --> java.io.IOException: CreateProcess: .\dossier\fichier.html error=193

    A chaque fois j'ai une erreur.

  6. #6
    Expert éminent
    Avatar de adiGuba
    Homme Profil pro
    Développeur Java/Web
    Inscrit en
    Avril 2002
    Messages
    13 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java/Web
    Secteur : Transports

    Informations forums :
    Inscription : Avril 2002
    Messages : 13 938
    Billets dans le blog
    1
    Par défaut
    Salut,


    "fichier.html"
    n'est pas un exécutable sous Windows... exec() sert à exécuter des programmes...

    a++

  7. #7
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    147
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Septembre 2006
    Messages : 147
    Par défaut
    Merci pour ta réponse.

    Ça devrait aller avec ça ?

    Desktop.open(new File("fichier.html"));

    Il me dit qu'il ne trouve pas le fichier.

    Et si je met le chemin entier, il ne me le trouve pas non plus mais fait plein d'autres erreurs en plus.

  8. #8
    Membre émérite
    Profil pro
    Architecte technique
    Inscrit en
    Mars 2002
    Messages
    966
    Détails du profil
    Informations personnelles :
    Âge : 52
    Localisation : France

    Informations professionnelles :
    Activité : Architecte technique

    Informations forums :
    Inscription : Mars 2002
    Messages : 966
    Par défaut
    Il faut le chemin absolu. Mais quelles sont les erreurs ???

  9. #9
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    147
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Septembre 2006
    Messages : 147
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Desktop.open(new File("C:/dossier/.../fichier.html"));
    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
    Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no jdic in java.library.path
    	at java.lang.ClassLoader.loadLibrary(Unknown Source)
    	at java.lang.Runtime.loadLibrary0(Unknown Source)
    	at java.lang.System.loadLibrary(Unknown Source)
    	at org.jdesktop.jdic.desktop.internal.impl.WinAPIWrapper.<clinit>(Unknown Source)
    	at org.jdesktop.jdic.desktop.internal.impl.WinUtility.getVerbCommand(Unknown Source)
    	at org.jdesktop.jdic.desktop.internal.impl.WinLaunchService.open(Unknown Source)
    	at org.jdesktop.jdic.desktop.Desktop.open(Unknown Source)
    	at xmlBuilder.xmlBuilder.actionPerformed(xmlBuilder.java:398)
    	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    	at javax.swing.AbstractButton.doClick(Unknown Source)
    	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
    	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
    	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.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(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)

  10. #10
    Expert confirmé
    Avatar de Baptiste Wicht
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2005
    Messages
    7 431
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2005
    Messages : 7 431
    Par défaut
    Il faut que tu mette jdic.dll dans un endroit accessible depuis le classpath

  11. #11
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    147
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Septembre 2006
    Messages : 147
    Par défaut
    Cool c'est bien ça, ça marche à merveille.

    Merci beaucoup !!

  12. #12
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    147
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Septembre 2006
    Messages : 147
    Par défaut
    Au fait, y'a pas moyen de mettre le chemin relatif ? Parce que mon jar ne se trouveras pas tout le temps au même endroit...

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. lancer acrobat reader (toute version) depuis excel
    Par boubou_s dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 30/06/2010, 07h20
  2. [WB14] Lancer word, excel, acrobat reader ?
    Par devdev dans le forum WebDev
    Réponses: 4
    Dernier message: 30/06/2009, 09h33
  3. Lancer Acrobat Reader en ligne de commande
    Par Rei Itchido dans le forum Windows
    Réponses: 0
    Dernier message: 22/04/2008, 10h00
  4. Comment exécuter Acrobat Reader automatiquement ?
    Par b.bilel dans le forum Débuter
    Réponses: 9
    Dernier message: 21/11/2007, 22h36
  5. Réponses: 12
    Dernier message: 08/06/2004, 08h39

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