Hello guys !
J'ai un ptit soucis avec mon applet java que jsuis en train de développer.
J'ai déjà pas mal codé en java, mais c'est la première fois que je fais une applet. Donc j'ai du chamboulé un peu mes habitudes pour mettre un init() à la place du main etc...
Quand je lance mon applet depuis Eclipse (run as > java applet) elle marche nickel. Par contre si je l'intègre dans du code html que voilà :
Il m'affiche l'erreur que voici :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 <html> <body style="margin:auto;"> <applet code="TestN.class" height="300" width="800"> </applet> </body> </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
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 java.lang.reflect.InvocationTargetException at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(Unknown Source) at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read) at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPropertyAccess(Unknown Source) at java.lang.System.getProperty(Unknown Source) at java.io.Win32FileSystem.getUserPath(Unknown Source) at java.io.Win32FileSystem.resolve(Unknown Source) at java.io.File.getAbsolutePath(Unknown Source) at javax.swing.filechooser.WindowsFileSystemView.isFloppyDrive(Unknown Source) at javax.swing.plaf.basic.BasicFileChooserUI$BasicFileView.getIcon(Unknown Source) at javax.swing.JFileChooser.getIcon(Unknown Source) at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxRenderer.getListCellRendererComponent(Unknown Source) at javax.swing.plaf.basic.BasicListUI.updateLayoutState(Unknown Source) at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(Unknown Source) at javax.swing.plaf.basic.BasicListUI$Handler.valueChanged(Unknown Source) at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source) at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source) at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source) at javax.swing.DefaultListSelectionModel.changeSelection(Unknown Source) at javax.swing.DefaultListSelectionModel.changeSelection(Unknown Source) at javax.swing.DefaultListSelectionModel.setSelectionInterval(Unknown Source) at javax.swing.JList.setSelectedIndex(Unknown Source) at javax.swing.plaf.basic.BasicComboPopup.setListSelection(Unknown Source) at javax.swing.plaf.basic.BasicComboPopup.access$300(Unknown Source) at javax.swing.plaf.basic.BasicComboPopup$Handler.itemStateChanged(Unknown Source) at javax.swing.JComboBox.fireItemStateChanged(Unknown Source) at javax.swing.JComboBox.selectedItemChanged(Unknown Source) at javax.swing.JComboBox.contentsChanged(Unknown Source) at javax.swing.AbstractListModel.fireContentsChanged(Unknown Source) at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxModel.setSelectedItem(Unknown Source) at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxModel.addItem(Unknown Source) at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxModel.access$900(Unknown Source) at javax.swing.plaf.metal.MetalFileChooserUI.doDirectoryChanged(Unknown Source) at javax.swing.plaf.metal.MetalFileChooserUI.access$1200(Unknown Source) at javax.swing.plaf.metal.MetalFileChooserUI$5.propertyChange(Unknown Source) at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source) at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source) at java.awt.Component.firePropertyChange(Unknown Source) at javax.swing.JFileChooser.setCurrentDirectory(Unknown Source) at javax.swing.JFileChooser.<init>(Unknown Source) at javax.swing.JFileChooser.<init>(Unknown Source) at TestN.<init>(TestN.java:30) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) 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) Exception : java.lang.reflect.InvocationTargetException
D'après ce que j'ai un peu cherché, c'est le genre d'erreur qui arrive quand ya pas de méthode init(). Pourtant mon applet comporte bien une méthode init(), pas de main, pas de constructeur. En gros pour la résumer (parce qu'elle fait 300 lignes actuellement) elle a cette structure :
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 /* Les imports */ public class TestN extends JApplet { /* Les variables */ public void init() { /* L'appel à toutes les fonctions nécessaires pour construire la GUI, instancier les variables, mettre les Listener etc... */ } /* Tout plein de fonctions appelées depuis init pour faire le sale boulot */ }
Comme c'est ma première applet jsuis pas tout à fait sur de l'avoir faite correctement, j'ai bien compris que init() était appelée au chargement de l'applet par le navigateur, mais je suis pas tout à fait sur de la bonne marche à suivre pour en créer une correctement.
En plus de cette classe principale j'ai 5 ou 6 autres classes à coté.
Ce qui me semble bizarre c'est que eclipse arrive sans problème à la lancer dans l'applet viewer :/
J'ai évidemment vérifié la présence des fichiers .class dans le dossier du fichier html, ils sont tous là mais ca marche pas. D'ailleurs au passage, si ya une meilleure méthode (genre un .jar plutot que 5 ou 6 .class) pour déployer facilement une applet, je suis preneur.
Bref si quelqu'un peut me filer un coup de main, je vous en remercierai d'avance !
Partager