Java:je n'arrive pas executer mon prg

Résolu/Fermé
domxaline - Modifié par domxaline le 2/05/2012 à 11:05
 domxaline - 2 mai 2012 à 12:06
Bonjour,
en executant mon prg,j'ai une boite à message apparait en disant
"fatal exception occured program will exit" OK

et encore erreur aussi
java.lang.NoSuchMethodError: main
Exception in thread "main"

import java.lang.annotation.*;
import java.lang.reflect.*;
@Retention(RetentionPolicy.RUNTIME)
@interface MySingle
{
 int value( );//this variable name must be value
}
public class Single 
{
 //annotate a method using a marker
	@MySingle(100)
	public static void myMeth( )
	{
		Single ob=new Single ();
		try
		{ 
			
			Method m=ob.getClass().getMethod("myMeth");
			MySingle anno=m.getAnnotation(MySingle.class);
			System.out.println("This value is:"+anno.value());
			//displays 100
		}
		catch(NoSuchMethodException exc)
		{
			System.out.println("Method not found.");
		}
		public static void main(String[]args)
		{
			myMeth();
		}		
	}
}



public static void main(String[]args)

main souligné
en pointant avec le curseur de souris m'indique
"void is an unvalid type for the variable main"

) après ce parenthèse souligné aussi
syntax error on token ")" ,; expected

A voir également:

2 réponses

KX Messages postés 16755 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 12 février 2025 3 020
2 mai 2012 à 11:08
Il faut fermer les accolades de la méthode myMeth avant de déclarer la méthode main
0
cool merci beaucoup,ça marche
0