ctsarsh 0 Newbie Poster

i need to convert this java code to java applet code

here in my java code:

import java.io.*;
import java.util.*;


public class fyp
 {
    	static int t_value=2;
	static int no_of_parameter = 0;
	String binary_setting;
	static int data[];
	static ArrayList<String> constraint = new ArrayList<String>();
	static ArrayList<String> seeding = new ArrayList<String>();
	static ArrayList<String> binary_cmd_list = new ArrayList<String>();
	static ArrayList<String> test_suite_list = new ArrayList<String>();


    public static void main (String[] args)
    {

     // reads the command line options
     for (int i=0;i<args.length;i++)
       {
         if (args[i].equals ("-i"))
           {
             String data_str = new String();
             // specify data values
             if (i+1<args.length)
              {
                i++;
                System.out.println ("Parameter =>"+args[i]);
                data_str = args[i];
              }
              // assign data values automatically to data by commas
              StringTokenizer s = new StringTokenizer (data_str,",");
              // count parameter
              int p = data_str.replaceAll("[^,]","").length();
              p++; // as an array size
              data = new int [p];
              int k =0;
              while (s.hasMoreTokens())
               {
                 data[k]=Integer.parseInt(s.nextToken());
                 k++;
               }
             }
       }

     generate_binary_input_combinations (t_value,binary_cmd_list);
     generate_test_set (binary_cmd_list,test_suite_list);
     display_list ("Final Pairwise Test Suite List",test_suite_list);

  }

  //*****************************************************************
  //           DISPLAY ANY STRING ARRAY LIST
  //*****************************************************************
   private final static void display_list (String title, ArrayList<String> list)
    {
     int i=0;
     System.out.println (title);
     for (Iterator it = list.iterator(); it.hasNext(); )
     {
       String s = (String)it.next();  // Downcasting is required pre Java 5.
       System.out.println ("i = "+i + "->"+s);
       i++;
     }
    }


   //*****************************************************************
   //           GENERATE POSSIBLE BINARY INPUT COMBINATIONS
   //           BASED ON THE SELECTION OF T VALUE
   //*****************************************************************
   private final static void generate_binary_input_combinations (int t_value,
                                                                 ArrayList<String> binary_cmd_list)
    {

      int limit =(int) Math.pow (2,data.length);

      // generate binary number in comb
      for (int i=0;i<limit;i++)
       {
         String comb = new String();
         comb = Integer.toBinaryString (i);
         while (comb.length()<data.length)
           comb ="0"+comb;

         // count the occurences of 1 in comb
         int no_of_one=0;
         for (int j=0;j<comb.length();j++)
          if (comb.charAt(j)=='1')
               no_of_one++;

         if (no_of_one==t_value)
          {
             binary_cmd_list.add(comb);
          }

        }

    }

   //*****************************************************************
   //           GENERATE PAIRWISE SET
   //*****************************************************************
   private final static void  generate_test_set (ArrayList<String> binary_cmd_list,
                                                 ArrayList<String> test_suite_list)
    {
     for (Iterator it = binary_cmd_list.iterator(); it.hasNext(); )
     {
       String s = (String)it.next();  // Downcasting is required pre Java 5.
       append_test_case (s, test_suite_list);
     }
    }


   //*****************************************************************
   //           APPEND TEST TO TEST SUITE LIST
   //*****************************************************************
   private final static void append_test_case (String binary_setting,
                                                  ArrayList<String> test_suite_list)
    {

    // copy the combinatorial matrix
      int[] comb=new int[t_value];
      int index=0;

      for (int i=0;i<binary_setting.length();i++)
        if(binary_setting.charAt(i)=='1') comb[index++]=data[i];

      System.out.println( "Interaction Setting => "+binary_setting);
      if (t_value==2)
        {
           for (int i=0;i<comb[0];i++)
             for (int j=0;j<comb[1];j++)
               {
                 // rearrange data correctly
                 int [] r = new int [data.length];
                 String test_case=new String("");
                 int layer=1;
                 for (int z=0;z<data.length;z++)
                   {
                     if (binary_setting.charAt(z)=='1')
                       {
                         if (layer==1)
                           r[z]=i;
                         else if (layer==2)
                           r[z]=j;
                         layer++;
                       }
                    else
                       {
                         Random generator = new Random();
              	         r[z]=generator.nextInt(data[z]);
                       }
                 }

                 for (int z=0;z<data.length;z++)
                   {
                     if (z>0)
                       test_case = test_case +":"+r[z];
                     else
                       test_case = test_case + r[z];
                   }
                 // check if the generated test case is already
                 // in the test_suite_list
                 if (!test_suite_list.contains(test_case))
                    test_suite_list.add (test_case);
             }
         }
   }

}

when i convert my java code to java applet code, there is no error, but when i run the code, the command prompt display

Exeption in thread "main" java.lang.NoSuchMethodError: main

can you please help me to solve my problem.
here is the code that i already converted as applet

//  <applet code="huwa" width="200" height="200"></applet>

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.util.StringTokenizer;
import javax.swing.JOptionPane;
import java.applet.*;


public class huwa extends Applet

{ 
	
    	static int t_value=2;
	static int no_of_parameter = 0;
	String binary_setting;
	static int data[];
	static ArrayList<String> binary_cmd_list = new ArrayList<String>();
	static ArrayList<String> test_suite_list = new ArrayList<String>();


	public static void init(String[] args)
 {

	String userInput = JOptionPane.showInputDialog("Enter Number");
	if (userInput.length() == 0)
	System.exit(0);
	// reads the command line options
	for (int i=0;i<args.length;i++) 
{
		if (args[i].equals ("-i")) 
{
		String data_str = new String();
		// specify data values
		if (i+1<args.length) {
                i++;
		JOptionPane.showMessageDialog( null, "Parameter => "+args[i]);
		userInput = args[i];
				}
			// assign data values automatically to data by commas
			StringTokenizer s = new StringTokenizer (userInput,",");
			// count parameter
			int p = userInput.replaceAll("[^,]","").length();
			p++; // as an array size
			data = new int [p];
			int k =0;
			while (s.hasMoreTokens()) 
 {
				data[k]=Integer.parseInt(s.nextToken());
				k++;
				}
			}
		}
		generate_binary_input_combinations (t_value,binary_cmd_list);
		generate_test_set (binary_cmd_list,test_suite_list);
		display_list ("Final Pairwise Test Suite List",test_suite_list);
		}
//*****************************************************************
//           DISPLAY ANY STRING ARRAY LIST
//*****************************************************************
	private final static void display_list (String title, ArrayList<String> list) 
{
		int i=0;
		JOptionPane.showMessageDialog( null, title);
		for (Iterator it = list.iterator(); it.hasNext(); ) {
			String s = (String)it.next(); 
		 // Downcasting is required pre Java 5.
			JOptionPane.showMessageDialog( null, "i = "+i + "->"+s);
			i++;
		}
	}
//*****************************************************************
//           GENERATE POSSIBLE BINARY INPUT COMBINATIONS
//           BASED ON THE SELECTION OF T VALUE
//*****************************************************************
	private final static void generate_binary_input_combinations (int t_value,ArrayList<String> binary_cmd_list)
 {
		int limit =(int) Math.pow (2,data.length);
		// generate binary number in comb
		for (int i=0;i<limit;i++) {
			String comb = new String();
			comb = Integer.toBinaryString (i);
			while (comb.length()<data.length)
			comb ="0"+comb;
			// count the occurences of 1 in comb
			int no_of_one=0;
			for (int j=0;j<comb.length();j++)
			if (comb.charAt(j)=='1')
			no_of_one++;
			if (no_of_one==t_value)
 {
			binary_cmd_list.add(comb);
			}
		}
	}
//*****************************************************************
//           GENERATE PAIRWISE SET
//*****************************************************************
	private final static void  generate_test_set (ArrayList<String> binary_cmd_list,ArrayList<String> test_suite_list)
 {
		for (Iterator it = binary_cmd_list.iterator(); 		
			it.hasNext(); ) 
{
		String s = (String)it.next(); 
		 // Downcasting is required pre Java 5.
		append_test_case (s, test_suite_list);
		}
	}
//*****************************************************************
//           APPEND TEST TO TEST SUITE LIST
//*****************************************************************
	private final static void append_test_case (String binary_setting,ArrayList<String> test_suite_list)
 {
		// copy the combinatorial matrix
		int[] comb=new int[t_value];
		int index=0;
		for (int i=0;i<binary_setting.length();i++)
		if(binary_setting.charAt(i)=='1') 		
		comb[index++]=data[i];
		JOptionPane.showMessageDialog( null, "Interaction Setting => "+binary_setting);
		if (t_value==2) {
			for (int i=0;i<comb[0];i++)
			for (int j=0;j<comb[1];j++) {
				// rearrange data correctly
				int [] r = new int [data.length];
				String test_case=new String("");
				int layer=1;
				for (int z=0;z<data.length;z++)
 {
		if (binary_setting.charAt(z)=='1') 
{
					if (layer==1)
						r[z]=i;
						else if (layer==2)
						r[z]=j;
						layer++;
					}
					else 
{
						Random generator = new Random();
							r[z]=generator.nextInt(data[z]);
					}
				}
				for (int z=0;z<data.length;z++)
 {
					if (z>0)
					test_case = test_case +":"+r[z];
					else
					test_case = test_case + r[z];
				}
				// check if the generated test case is already
				// in the test_suite_list
				if (!test_suite_list.contains(test_case));
				test_suite_list.add (test_case);
			}
		}
			
	}
}
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.