I created a program, which I will include the source below with a problem. It appears to compile fine, but I get an error when I try to run it. The error is: "Exception in thread "main" java.lang.NoSuchMethodError: main." What does this error mean?

/*   This program will allow the user to select a country"s curency and find          */
/*   what the equivalent is in another.  These calculations are based on the          */
/*     values posted on the www.x-rates.com web site on Thursday, November 18,        */
/*     2004.  The site had these two items as disclaimers:                            */
/*       1)  "The given values on this site are gathered from the Federal Reserve     */
/*           Bank of New York, representing the 12 noon buying rates and the          */
/*           doubleernational Monetary Fund, according to their availability.         */
/*       2)  Values and dates are believed to be reliable but this site makes no      */
/*           warranties regarding these values, fitness for a particular purpose,     */
/*           accuracy or availability."                                               */
/*     Written by:        Andrew Q. Western                                           */
/*     Creation Date:     January 13, 2005                                            */
/*     Revision History:  January 20, 2005 - Cleaned up the output of the converted   */
/*                                           currency value to be only two decimal    */
/*                                           places.                                  */ 

	import java.io.*;			/* This is for the system.io       */
	import java.util.*;			/* This is for allowing user input */

	public class CurrencyConv1
	{
	 
	     String Menu_Opt;			/* Menu Option */
	     String Menu_ID;			
	     String Opt_Num;
	     float  Org_Curr_Amt;		/* Original Currency Amount */    
	     double   New_Curr_Amt;		/* New Currency Amount      */         
	     String  Currency_Desc[] = { "American Dollar (USD) " , "Australian Dollar (AUD) " ,
	       "Brazilian Real (BRL) " , "British Pound (GBP) " , "Canadian Dollar (CAD) " ,
	       "Chinese Yuan (CNY) " , "Danish Krone (DKK) " , "Euro (EUR) " , "Hong Kong Dollar (HKD) " , 
	       "Indian Rupee (INR) " , "Japanese Yen (JPY) " , "Malaysian Ringgit (MYR) " , "Mexican Peso (MXN) " ,
	       "New Zealand Dollar (NZD) " , "Norwegian Kroner (NOK) " , "Singapore Dollar (SGD) " , 
	       "South African Rand (ZAR) " , "South Korean Won (KRW) " , "Sri Lanka Rupee (LKR) " , 
	       "Swedish Krona (SEK) " , "Swiss Franc (CHF) " , "Taiwan Dollar (TVD) " , "Thai Baht (THB) " ,
	       "Venezuelan Bolivar (YEB) " }; /* Descriptions of each of the currency types to be converted */
	     	     	
	     BufferedReader inStr = new BufferedReader(new InputStreamReader(System.in));
	     Scanner input = new Scanner(System.in);
    
        public void main (String[] arguments) throws IOException 
	     { 
	     USD_Menu();
	     }
        public void USD_Menu() throws IOException
	     { 
	     double USD_to_AUD = 1.28436;     /* Australian Dollar (AUD)   */     
	     double USD_to_BRL = 2.7675;      /* Brazilian Real (BRL)      */    
	     double USD_to_GBP = 0.540132;    /* British Pound (GBP)       */    
	     double USD_to_CAD = 1.207;       /* Canadian Dollar (CAD)     */    
	     double USD_to_CNY = 8.2765;      /* Chinese Yuan (CNY)        */    
	     double USD_to_DKK = 5.7225;      /* Danish Krone (DKK)        */    
	     double USD_to_EUR = 0.770297;    /* Euro (EUR)                */    
	     double USD_to_HKD = 7.7767;      /* Hong Kong Dollar (HKD)    */    
	     int    USD_to_INR = 45;          /* Indian Rupee (INR)        */    
	     double USD_to_JPY = 104.23;      /* Japanese Yen (JPY)        */    
	     double USD_to_MYR = 3.8;         /* Malaysian Ringgit (MYR)   */     
	     double USD_to_MXN = 11.342;      /* Mexican Peso (MXN)        */     
	     double USD_to_NZD = 1.41123;     /* New Zealand Dollar (NZD)  */    
	     double USD_to_NOK = 6.2644;      /* Norwegian Kroner (NOK)    */   
	     double USD_to_SGD = 1.6538;      /* Singapore Dollar (SGD)    */   
	     double USD_to_ZAR = 6.0284;      /* South African Rand (ZAR)  */   
	     int    USD_to_KRW = 1069;        /* South Korean Won (KRW)    */   
	     double USD_to_LKR = 104.88;      /* Sri Lanka Rupee (LKR)     */   
	     double USD_to_SEK = 6.9108;      /* Swedish Krona (SEK)       */   
	     double USD_to_CHF = 1.1691;      /* Swiss Franc (CHF)         */   
	     double USD_to_TVD = 32.635;      /* Taiwan Dollar (TVD)       */   
	     double USD_to_THB = 40.16;       /* Thai Baht (THB)           */   
	     double USD_to_YEB = 1915.2;      /* Venezuelan Bolivar (YEB)  */ 
	     CurrencyConv1 Rename = new CurrencyConv1();		
	
		System.out.println("\nCurrency Conversion"); 
		System.out.println(Rename.Currency_Desc[0]+"Conversion Menu\n");
		System.out.println("");
		System.out.println("A02.  USD to AUD        Y02.  Transfer to AUD Conversion Menu");
		System.out.println("A03.  USD to BRL        Y03.  Transfer to BRL Conversion Menu");
		System.out.println("A04.  USD to GBP        Y04.  Transfer to GBP Conversion Menu");
		System.out.println("A05.  USD to CAD        Y05.  Transfer to CAD Conversion Menu");
		System.out.println("A06.  USD to CNY        Y06.  Transfer to CNY Conversion Menu");
		System.out.println("A07.  USD to DKK        Y07.  Transfer to DKK Conversion Menu");

		System.out.println("A08.  USD to EUR        Y08.  Transfer to EUR Conversion Menu");
		System.out.println("A09.  USD to HKD        Y09.  Transfer to HKD Conversion Menu");
		System.out.println("A10.  USD to INR        Y10.  Transfer to INR Conversion Menu");
		System.out.println("A11.  USD to JPY        Y11.  Transfer to JPY Conversion Menu");
		System.out.println("A12.  USD to MYR        Y12.  Transfer to MYR Conversion Menu");
		System.out.println("A13.  USD to MXN        Y13.  Transfer to MXN Conversion Menu");
		System.out.println("A14.  USD to NZD        Y14.  Transfer to NZD Conversion Menu");
		System.out.println("A15.  USD to NOK        Y15.  Transfer to NOK Conversion Menu");
		System.out.println("A16.  USD to SGD        Y16.  Transfer to SGD Conversion Menu");
		System.out.println("A17.  USD to ZAR        Y17.  Transfer to ZAR Conversion Menu");
		System.out.println("A18.  USD to KRW        Y18.  Transfer to KRW Conversion Menu");
		System.out.println("A19.  USD to LKR        Y19.  Transfer to LKR Conversion Menu");
		System.out.println("A20.  USD to SEK        Y20.  Transfer to SEK Conversion Menu");
		System.out.println("A21.  USD to CHF        Y21.  Transfer to CHF Conversion Menu");
		System.out.println("A22.  USD to TVD        Y22.  Transfer to TVD Conversion Menu");
		System.out.println("A23.  USD to THB        Y23.  Transfer to THB Conversion Menu");
		System.out.println("A24.  USD to YEB        Y24.  Transfer to YEB Conversion Menu\n");
		System.out.println("Z99.  Exit Program");
		System.out.print("Option: "); 
		
		/* Read in the menu option selected and extract out the different parts of it. */ 
		Rename.Menu_Opt = inStr.readLine();
		Rename.Menu_Opt = Rename.Menu_Opt.toUpperCase();    /* Convert the menu option to upper case, just in case  */
						      /* the user entered it in lower case letters.  */
		Rename.Menu_ID = Rename.Menu_Opt.substring(0 , 1);  /* Extract the first character of the menu option. */
		Rename.Opt_Num = Rename.Menu_Opt.substring(1 , 3);  /* Extract the last two characters of the menu option. */
		int a = Integer.parseInt(Rename.Opt_Num);    /* Convert the last two characters of the menu option to  */ 
						      /* allow the use of "Case" logic.  */

		/* Check to see if the user has requested to exit the program. */
		if (Rename.Menu_Opt.equals( "Z99" ) )
		 {
		return;
		 }

		/* Make sure that the user enters a valid menu option number. */
		if (a < 2 || a > 24 )
		 {
		System.out.println("Invalid menu option, program is now exiting.");
		return;
		 }

		if (Rename.Menu_ID.equals( "A" ) )
		 {
		switch (a)
		     {
			case 2:
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_AUD;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[1], Rename.New_Curr_Amt);
				break;
			     }
			case 3:
		 	     {
		 		System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_BRL;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[2], Rename.New_Curr_Amt);
		 		break;
			     }
			case 4: 
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_GBP;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[3], Rename.New_Curr_Amt);
				break;
			     }
			case 5: 
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_CAD;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[4], Rename.New_Curr_Amt);
				break;
			     }
			case 6: 
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_CNY;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[5], Rename.New_Curr_Amt);
				break;
			     }	
			case 7:				
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_DKK;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[6], Rename.New_Curr_Amt);
				break;
			     }
			case 8: 	
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_EUR;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[7], Rename.New_Curr_Amt);
				break;
			     }
			case 9: 	
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_HKD;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[8], Rename.New_Curr_Amt);
				break;
			     }
			case 10:	
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_INR;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[9], Rename.New_Curr_Amt);
				break;
			     }
			case 11: 	
			     {
				System.out.print("Please enter your value of "+ Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_JPY;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[10], Rename.New_Curr_Amt);
				break;
			     }
			case 12:
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_MYR;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[11], Rename.New_Curr_Amt);
				break;
			     }
			case 13:
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_MXN;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[12], Rename.New_Curr_Amt);
				break;
			     }
			case 14:
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_NZD;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[13], Rename.New_Curr_Amt);
				break;
			     }		
			case 15: 	
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_NOK;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[14], Rename.New_Curr_Amt);
				break;	
			     }	
			case 16: 	
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_SGD;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[15], Rename.New_Curr_Amt);
				break;
			     }	
			case 17:
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_ZAR;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[16], Rename.New_Curr_Amt);
				break;	
			     }
			case 18: 	
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_KRW;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[17], Rename.New_Curr_Amt);
				break;
			     }
		 	case 19: 	
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_LKR;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[18], Rename.New_Curr_Amt);
				break;
			     }
			case 20:
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_SEK;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[19], Rename.New_Curr_Amt);
				break;
			     }
			case 21: 	
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_CHF;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[20], Rename.New_Curr_Amt);
				break;
			     }
			case 22: 	
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_TVD;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[21], Rename.New_Curr_Amt);
				break;
			     }
			case 23: 	
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_THB;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[22], Rename.New_Curr_Amt);
				break;
			     }
			case 24:
			     {
				System.out.print("Please enter your value of " +Rename.Currency_Desc[0]);
				Rename.Org_Curr_Amt = input.nextFloat();
				Rename.New_Curr_Amt = Rename.Org_Curr_Amt * USD_to_YEB;
				System.out.printf("\nYour Equivalent %s is %.2f\n", Rename.Currency_Desc[23], Rename.New_Curr_Amt);
				break;
			     }		
		     } 
		   } else if (Rename.Menu_ID.equals( "Y" ) )
		   {
		switch (a)
		     {
			case 2:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			}	
			case 3: 
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 4:  
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 5:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 6:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 7:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 8:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 9:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 10:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 11:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 12:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 13:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 14:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 15:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 16:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 17:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 18:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 19:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 20:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 21:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 22:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 23:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
			case 24:
			{
			System.out.println("I am sorry, but that option is not supported right now.");
			break;
			} 		
		     }
		   } else System.out.println("Invalid menu option, program is now exiting.");

	     }
	}

you forgot the main method:

public static void main(String[] args)
{
}

Do you mean that I have to call this or what? Because I have it defined and it calls the USD_Menu. (I'm confused).

it's not static.

It MUST have the exact signature:

public static void main(String[] args) //you can call the string array whatever
{
}

I first changed main to be static and it said that USD_Menu needed to be static too. I then changed USD_Menu too, but it now says that non-static variables can't be referenced from a static context.

Hi everyone,

See what you did.

public void main (String[] arguments) throws IOException 
{ 
USD_Menu();
}

Do this instead(call it at the end of the class)

public static void main(String[] args) throws IOException 
{ 
CurrencyConv1 a = new CurrencyConv1();
a.USD_Menu();
}

From what i see you do not have the very basic understanding of Java but
don't worry too much about it.

I suggest you go to sun's site and download the awt tutorial and learn the basics from there and you will realize that you will understand certain concepts easier.

Yours Sincerely

Richard West

Did you happen to copy my program into a source editor and try to compile it yourself? I am getting a lot more errors than before. (Too Many to mention here).

This is still a problem.

You really need to work on how it's written.

Maybe if I have time I'll look at it, but right now I don't.

I put my program back to the form where it compiles clean, but produces the error upon running (Just like the code I posted here in an earlier message).

In your main method, you call some method, but for some reason that method also creates another instance of the class your already in and continues from there. I think you should put this all under the main method, and maybe it won't be so confusing for you.

You already have a bunch of values that represent the currency amounts. The best thing to do, would be store these in an array, and then start calculating them through a loop. I know this is possible, because I have AP Comp Sci, and had this same project except ours had to include a gui, and some other advanced things.

Once I get the program working with all the methods, I will add logic to read in the currency conversion amounts from a *.csv file and load them into a 24 x 24 array. I know how I'm going to do this, so I want to get the other part working first.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.