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

Applets Java Discussion :

problème avec un applet


Sujet :

Applets Java

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 3
    Points : 2
    Points
    2
    Par défaut problème avec un applet
    je lance cet applet
    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
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
     
    import javax.swing.JPanel;
    import javax.swing.JApplet;
    import javax.swing.JMenuBar;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import java.awt.Rectangle;
    import java.io.File;
     
    import javax.swing.JComboBox;
    import javax.swing.JLabel;
     
    public class Menu extends JApplet {
     
    	/**
             * 
             */
    	private static final long serialVersionUID = 1L;
    	private JPanel jContentPane = null;
    	private JMenuBar jJMenuBar = null;
    	private JComboBox jComboBox = null;
    	private JLabel jLabel = null;
    	private JMenu jMenu = null;
    	private JMenuItem jMenuItem = null;
    	private JLabel jLabel1 = null;
    	/**
             * This method initializes jJMenuBar    
             *      
             * @return javax.swing.JMenuBar 
             */
    	private JMenuBar getJJMenuBar() {
    		if (jJMenuBar == null) {
    			jJMenuBar = new JMenuBar();
    			jJMenuBar.add(getJMenu());
    		}
    		return jJMenuBar;
    	}
     
    	/**
             * This method initializes jComboBox    
             *      
             * @return javax.swing.JComboBox        
             */
    	private JComboBox getJComboBox() {
    		int i;
    		if (jComboBox == null) {
    			jComboBox = new JComboBox();
    			jComboBox.setBounds(new Rectangle(14, 48, 255, 34));
    			jComboBox.setSelectedIndex(-1);
    			File f = new File("C://");
    			String[]fichier= f.list();
    			System.out.println(fichier.length);
    			for (i=0;i<=fichier.length-1;i++)jComboBox.insertItemAt(fichier[i],i);
    		}
    		return jComboBox;
    	}
     
    	/**
             * This method initializes jMenu        
             *      
             * @return javax.swing.JMenu    
             */
    	private JMenu getJMenu() {
    		if (jMenu == null) {
    			jMenu = new JMenu();
    			jMenu.setText("version");
    			jMenu.add(getJMenuItem());
    		}
    		return jMenu;
    	}
     
    	/**
             * This method initializes jMenuItem    
             *      
             * @return javax.swing.JMenuItem        
             */
    	private JMenuItem getJMenuItem() {
    		if (jMenuItem == null) {
    			jMenuItem = new JMenuItem();
    			jMenuItem.setText("version 1.0");
    		}
    		return jMenuItem;
    	}
     
    	/**
             * @param args
             */
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
     
    	}
     
    	/**
             * This is the xxx default constructor
             */
    	public Menu() {
    		super();
    	}
     
    	/**
             * This method initializes this
             * 
             * @return void
             */
    	public void init() {
    		this.setSize(300, 200);
    		this.setJMenuBar(getJJMenuBar());
    		this.setContentPane(getJContentPane());
    	}
     
    	/**
             * This method initializes jContentPane
             * 
             * @return javax.swing.JPanel
             */
    	private JPanel getJContentPane() {
    		if (jContentPane == null) {
    			jLabel1 = new JLabel();
    			jLabel1.setBounds(new Rectangle(19, 90, 261, 35));
    			jLabel1.setText("                                   hote");
    			jLabel = new JLabel();
    			jLabel.setBounds(new Rectangle(14, 4, 255, 30));
    			jLabel.setText("Fichier sur votre disque dur");
    			jContentPane = new JPanel();
    			jContentPane.setLayout(null);
    			jContentPane.add(getJComboBox(), null);
    			jContentPane.add(jLabel, null);
    			jContentPane.add(jLabel1, null);
    		}
    		return jContentPane;
    	}
     
    }
    et j'obtient l'erreur suivante (dans une page html):
    charger : classe Menu.java introuvable.
    java.lang.ClassNotFoundException: Menu.java
    at sun.applet.AppletClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadCode(Unknown Source)
    at sun.applet.AppletPanel.createApplet(Unknown Source)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(Unknown Source)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: (Le chemin d'accès spécifié est introuvable)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at sun.net.http://www.protocol.file.FileURLConn...onnect(Unknown Source)
    at sun.net.http://www.protocol.file.FileURLConn...Stream(Unknown Source)
    at sun.applet.AppletClassLoader.getBytes(Unknown Source)
    at sun.applet.AppletClassLoader.access$100(Unknown Source)
    at sun.applet.AppletClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 10 more
    charger : classe Menu introuvable.
    java.lang.ClassNotFoundException: Menu
    at sun.applet.AppletClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadCode(Unknown Source)
    at sun.applet.AppletPanel.createApplet(Unknown Source)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(Unknown Source)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: (Le fichier spécifié est introuvable)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at sun.net.http://www.protocol.file.FileURLConn...onnect(Unknown Source)
    at sun.net.http://www.protocol.file.FileURLConn...Stream(Unknown Source)
    at sun.applet.AppletClassLoader.getBytes(Unknown Source)
    at sun.applet.AppletClassLoader.access$100(Unknown Source)
    at sun.applet.AppletClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 10 more
    charger : classe Menu introuvable.
    java.lang.ClassNotFoundException: Menu
    at sun.applet.AppletClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadCode(Unknown Source)
    at sun.applet.AppletPanel.createApplet(Unknown Source)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(Unknown Source)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: (Le fichier spécifié est introuvable)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at sun.net.http://www.protocol.file.FileURLConn...onnect(Unknown Source)
    at sun.net.http://www.protocol.file.FileURLConn...Stream(Unknown Source)
    at sun.applet.AppletClassLoader.getBytes(Unknown Source)
    at sun.applet.AppletClassLoader.access$100(Unknown Source)
    at sun.applet.AppletClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 10 more
    java.security.AccessControlException: access denied (java.io.FilePermission C:\ 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.checkRead(Unknown Source)
    at java.io.File.list(Unknown Source)
    at Menu.getJComboBox(Menu.java:51)
    at Menu.getJContentPane(Menu.java:126)
    at Menu.init(Menu.java:108)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    java.security.AccessControlException: access denied (java.io.FilePermission C:\ 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.checkRead(Unknown Source)
    at java.io.File.list(Unknown Source)
    at Menu.getJComboBox(Menu.java:51)
    at Menu.getJContentPane(Menu.java:126)
    at Menu.init(Menu.java:108)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    java.security.AccessControlException: access denied (java.io.FilePermission C:\ 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.checkRead(Unknown Source)
    at java.io.File.list(Unknown Source)
    at Menu.getJComboBox(Menu.java:51)
    at Menu.getJContentPane(Menu.java:126)
    at Menu.init(Menu.java:108)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Comment faire pour eviter l'erreur!!
    merci

  2. #2
    Rédacteur
    Avatar de eclesia
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    2 108
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 108
    Points : 3 203
    Points
    3 203
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    charger : classe Menu.java introuvable.
    java.lang.ClassNotFoundException: Menu.java
    ca c'est qu'il ne trouve pas ta classe Menu.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    java.security.AccessControlException: access denied (java.io.FilePermission C:\ read)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    Ca, ca veut dire que ton programme essai d'acceder a des donnees du pc ou d'etablir une communication. CE QUI INTERDIT (pour raison de securite) par la java virtual machine, ce qui est tout a fait normal. (sinon on verrait fleurir des applets mal intentionnes partout)

    Pour enlever cette securite il faut que ton archive (.jar) soit sign􏻩. Et meme dans ce cas, une confirmation serat demande a l'utilisateur.

  3. #3
    Candidat au Club
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 3
    Points : 2
    Points
    2
    Par défaut
    Comment signer son applet?

  4. #4
    Rédacteur
    Avatar de eclesia
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    2 108
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 108
    Points : 3 203
    Points
    3 203
    Par défaut
    c'est a ce demandé si tu as cherché.

    http://www.developpez.net/forums/showthread.php?t=18553

  5. #5
    Candidat au Club
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 3
    Points : 2
    Points
    2
    Par défaut
    Merci

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

Discussions similaires

  1. Problème avec mon Applet
    Par gimpycpu dans le forum Applets
    Réponses: 1
    Dernier message: 06/02/2009, 12h47
  2. débutant : problème avec ma premiere applet
    Par patsolaar dans le forum Applets
    Réponses: 5
    Dernier message: 06/08/2007, 15h23
  3. Problême de Socket avec un applet java (RMI/policy)
    Par Vesperal dans le forum API standards et tierces
    Réponses: 3
    Dernier message: 12/04/2006, 12h00
  4. Problème de connexion avec un applet
    Par bigben89 dans le forum Applets
    Réponses: 3
    Dernier message: 08/03/2006, 17h41
  5. Réponses: 3
    Dernier message: 16/09/2005, 10h01

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