Programming Noob
Programming Noob

Reputation: 1845

Imported project in Eclipse doesn't run, says - 'Editor does not contain a main type.'

I shifted a few Java projects from a Windows PC to Ubuntu by exporting it 'via archival file storage' i.e. a zip file, and importing with the same method.

When I was importing it back to Eclipse, it said I needed to create a blank project first to import from an archival file. So I created a new dummy java project and them imported it. But now when I compile it doesn't allow me to saying 'Editor doesn't contain main type'.

Since I'm too new to attach a screen shot right here, I'm uploading it HERE. What do I do now?

Edit: The program I'm trying to compile is a simple program demonstrating different types of sorting. In case you feel you should see it, here it is:

import java.io.PrintStream;
import java.util.LinkedList;
import java.util.Queue;


public class Sorting
{
    public static void print_r(char[] arr)
    {
        for(int i=0;i<arr.length;i++)
            System.out.print(arr[i]);
        System.out.println("\n-----");
    }

    public static void print_r_int(int[] arr)
    {
        for(int i=0;i<arr.length;i++)
            System.out.println(arr[i]);

        System.out.println("\n-----");
    }

    public static void main(String sar[])
    {
        String st=new String("jsahen");
        PrintStream oo=System.out;

        /*char ar1[]=st.toCharArray();
        mergeSort(ar1,0,ar1.length-1);
        print_r(ar1);*/

        /*char ar2[]=st.toCharArray();
        quickSort(ar2,0,ar2.length-1);
        print_r(ar2);*/

        /*char ar3[]=st.toCharArray();
        insertionSort(ar3);
        print_r(ar3);*/

        int ar3[]={215,64,25,3,541,584,68,14,69};
        recursiveRadixLSD(ar3,1);
        print_r_int(ar3);
    }

    public static void recursiveRadixLSD(int[] str,int digitFromRight)
    {
        if(digitFromRight==4)
            return;
        LinkedList<Integer>[] q=new LinkedList[10];

        for(int i:str)
        {
            int t=i/(int)(Math.pow(10, digitFromRight-1));
            int rem=t%10;
            if(q[rem]==null)
                q[rem]=new LinkedList<Integer>();
            q[rem].add(i);
        }

        int c=0;
        for(int i=0;i<10;i++)
        {
            while(q[i]!=null&&!q[i].isEmpty())
                str[c++]=q[i].remove();
        }

        recursiveRadixLSD(str,digitFromRight+1);
    }

    public static void insertionSort(char[] str)
    {
        if(!(str.length>1))
            return;

        else
        {
            int wall;

            for(wall=1;wall<=str.length-1;wall++)
            {
                char t=str[wall];
                int ind=wall;

                while(ind>=1&&str[ind-1]>t)
                {
                    str[ind]=str[ind-1];
                    ind--;
                }
                str[ind]=t;


            }



        }

    }

    public static void quickSort (char[] str,int st,int en)
    {
        if(st>=en)
            return;

        int j=partition(str,st,en);
        quickSort(str,st,j-1);
        quickSort(str,j+1,en);
    }
    public static int partition (char[] str,int st,int en)
    {
        if(st==en)
            return 0;
        char a=str[st];
        int left=st;
        int right=en;

        boolean go=true;

        while(go)
        {
            while(left<=en&&str[left]<=a)
                left++;

            while(right>=st&&str[right]>a)
                right--;

            if(left<right)
            {
                char t=str[left];
                str[left]=str[right];
                str[right]=t;
            }
            else
            {
                str[st]=str[right];
                str[right]=a;
                return right;
            }
        }


        return -1;
    }
    public static void mergeSort (char[] str,int st,int en)
    {
        if(st==en)
            return;
        int mid=(st+en)/2;
        char ret[]=new char[str.length];
        mergeSort(str,st,mid);
        mergeSort(str,mid+1,en);

        int i,j;
        int k=0;
        for(i=st,j=mid+1;i<=mid&&j<=en;)
        {
            if(str[i]>str[j])
            {
                ret[k++]=str[j++];
            }
            else
            {
                ret[k++]=str[i++];
            }
        }

        while(i<=mid)
            ret[k++]=str[i++];

        while(j<=en)
            ret[k++]=str[j++];

        for(int l=st;l<=en;l++)
            str[l]=ret[l-st];


    }
}

Upvotes: 1

Views: 7741

Answers (3)

teambob
teambob

Reputation: 2084

After check the build path this was still happening to me. So I entered the main class manually in the Run Configuration dialog and it worked.

Upvotes: 0

Bohemian
Bohemian

Reputation: 424983

  1. Open the java class for editing
  2. Right-click anywhere in the editor window (where the source text is)
  3. Select Run as > Java Application

Upvotes: 0

stacker
stacker

Reputation: 68942

Your folder Scratch/src isn't recognized (configured) as source folder by eclipse. Either you move th source files to src or you add Scratch/src as source folder. Right click on project -> Properties, choose Java Build Path from the right.

Upvotes: 2

Related Questions