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 :

Problème d'éxecution de mon fichier .class


Sujet :

Langage Java

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    27
    Détails du profil
    Informations personnelles :
    Âge : 38
    Localisation : France, Finistère (Bretagne)

    Informations forums :
    Inscription : Avril 2007
    Messages : 27
    Points : 20
    Points
    20
    Par défaut Problème d'éxecution de mon fichier .class
    Bonjour,

    j'ai un problème quand je lance mon fichier .class :

    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
     
    import java.util.Arrays;
    import java.util.Properties;
    import java.util.Set;
    import javax.management.ObjectName;
    import javax.management.j2ee.ManagementHome;
    import javax.management.j2ee.Management;
    import javax.management.j2ee.statistics.JVMStats;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
     
    public class HeapSizeRetriever {
     
    	public static void main(String args[]) {
    		try {
    			Properties props = new Properties();
    			props.setProperty(Context.PROVIDER_URL, "iiop://glenan:9999");
    			Context ic = new InitialContext(props);
    			Object obj = ic.lookup("ejb/mgmt/MEJB");
    			ManagementHome mejbHome = (ManagementHome) PortableRemoteObject
    					.narrow(obj, ManagementHome.class);
    			Management mejb = mejbHome.create();
    			ObjectName jvmQuery = new ObjectName("*:j2eeType=JVM,*");
    			Set s = mejb.queryNames(jvmQuery, null);
    			ObjectName jvmMBean = (ObjectName) s.iterator().next();
    			boolean hasStats = ((Boolean) mejb.getAttribute(jvmMBean,
    					"statisticsProvider")).booleanValue();
    			if (hasStats) {
    				JVMStats stats = (JVMStats) mejb
    						.getAttribute(jvmMBean, "stats");
    				String[] statisticNames = stats.getStatisticNames();
    				if (Arrays.asList(statisticNames).contains("heapSize")) {
    					System.out.println("Heap size: " + stats.getHeapSize());
    				}
    			}
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    }
    il me met une erreur comme celle-ci.
    j'ai chercher sur google pas trouver, ou alors pas compris

    il me renvoi cette erreur

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    	at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
    	at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
    	at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
    	at javax.naming.InitialContext.lookup(InitialContext.java:351)
    	at HeapSizeRetriever.main(HeapSizeRetriever.java:19)
    Merci d'avance pour les aides

  2. #2
    Membre habitué Avatar de Tazmanian Devil
    Profil pro
    Inscrit en
    Février 2007
    Messages
    119
    Détails du profil
    Informations personnelles :
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Février 2007
    Messages : 119
    Points : 149
    Points
    149
    Par défaut
    Il te manque l'initialisation d'une propriétée :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    props.put(Context.INITIAL_CONTEXT_FACTORY,".....");
    ou tu dois renseigner la factory à utiliser.
    Vu
    The most fundamental property key is "java.naming.factory.initial", which corresponds to the Context.INITIAL_CONTEXT_FACTORY constant. The value for this property specifies the name of a factory class in a JNDI service provider. It is the job of this factory class to create an InitialContext that is appropriate for its service and hand the object back to us.

Discussions similaires

  1. Problème de servlet dans mon fichier web.xml
    Par bel09 dans le forum Spring
    Réponses: 4
    Dernier message: 07/05/2009, 17h26
  2. [ODBC] problème de table dans mon fichier avec ODBC
    Par cdevl32 dans le forum PHP & Base de données
    Réponses: 0
    Dernier message: 28/03/2009, 13h55
  3. problème d'affichage de mon fichier html
    Par sadem dans le forum ASP.NET
    Réponses: 6
    Dernier message: 27/03/2009, 11h07
  4. Problème d'éxecution dans mon programme
    Par mouchT8 dans le forum C
    Réponses: 8
    Dernier message: 16/05/2008, 01h36
  5. problème avec importation d'un fichier.class
    Par M.a.n.u. dans le forum NetBeans
    Réponses: 4
    Dernier message: 10/10/2007, 09h23

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