Bonjour,
NB : J'ai déja posté dans un forum plus "générique" de developpez.com, mais dans mon développement je suis arrivé à me spécialiser donc si je fais ce lien vers l'autre article c'est juste pour situer le contexte, si besoin.
J'ai créé un lanceur en java, le lanceur se lance exécute mon application et se ferme lorsque celle-ci à terminée.
Je suis newbie en java donc il y a surement des lignes qui sont inutiles, je suis parti d'un modèle par défaut...
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 package MonAppli; import org.jdesktop.application.Application; import org.jdesktop.application.SingleFrameApplication; import javax.swing.JOptionPane; /** * The main class of the application. */ public class MonAppli extends SingleFrameApplication { /** * At startup create and show the main frame of the application. */ @Override protected void startup() { show(new MonAppliView(this)); } /** * This method is to initialize the specified window by injecting resources. * Windows shown in our application come fully initialized from the GUI * builder, so this additional configuration is not needed. */ @Override protected void configureWindow(java.awt.Window root) { } /** * A convenient static getter for the application instance. * @return the instance of MonAppli */ public static MonAppli getApplication() { return Application.getInstance(MonAppli.class); } /** * Main method launching the application. */ public static void main(String[] args) { launch(MonAppli.class, args); // Parametre /S[NumSequence] ex.: /S0123456789 String AParam = ""; Boolean IsValidArguments = false; for (int I = 0; I < args.length; I++) { if (args[I].startsWith("/S")) { AParam = args[I]; IsValidArguments = true; break; } } //JOptionPane.showMessageDialog(null, args, "Arguments", JOptionPane.INFORMATION_MESSAGE); String Cmd = "C:\\Program Files\\MonAppli\\MonAppli.exe" + " " + AParam; //JOptionPane.showMessageDialog(null, Cmd, "Cmd", JOptionPane.INFORMATION_MESSAGE); try { if (IsValidArguments) try { Runtime r = Runtime.getRuntime(); Process p = r.exec(Cmd); // attend la fin de l'execution ? p.waitFor(); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Erreur d'execution " + Cmd + " : " + e.toString(), "Erreur", JOptionPane.WARNING_MESSAGE); e.printStackTrace(); } } finally { System.exit(0); } } }
J'ai activé le projet pour fonctionner avec java web start, depuis le navigateur j'ai un lien :
Le télécharagement se déroule normalement et la splash java apparait mais mon lanceur ne s'exécute pas...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 <a class="buttonstandard90" href="Scripts/MonAppli/launch.jnlp">MonAppli</a>
Je sais que Java web start sert surtout à déployer mais j'aimerais qu'il lance automatiquement mon lanceur une fois téléchargé. Je ne vois pas quoi modifier.....
Partager