Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7177379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:42:04+00:00 2026-05-28T16:42:04+00:00

I can’t seem to run the following code in Eclipse. I do have a

  • 0

I can’t seem to run the following code in Eclipse. I do have a main method and this is the currently opened file. I even tried the “Run As” option but I keep getting this error: “editor does not contain a main type”. What am I doing wrong here?

 public class cfiltering {

    /**
     * @param args
     */

    //remember this is just a reference
    //this is a 2d matrix i.e. user*movie
    private static int user_movie_matrix[][];

    //remember this is just a reference
    //this is a 2d matrix i.e. user*user and contains
    //the similarity score for every pair of users.
    private float user_user_matrix[][]; 


    public cfiltering()
    {
        //this is default constructor, which just creates the following:
        //ofcourse you need to overload the constructor so that it takes in the dimensions

        //this is 2d matrix of size 1*1
        user_movie_matrix=new int[1][1];
        //this is 2d matrix of size 1*1
        user_user_matrix=new float[1][1];
    }

    public cfiltering(int height, int width)
    {
        user_movie_matrix=new int[height][width];
        user_user_matrix=new float[height][height];
    }


    public static void main(String[] args) {
        //1.0 this is where you open/read file
        //2.0 read dimensions of number of users and number of movies
        //3.0 create a 2d matrix i.e. user_movie_matrix with the above dimensions. 
        //4.0 you are welcome to overload constructors i.e. create new ones. 
        //5.0 create a function called calculate_similarity_score 
        //you are free to define the signature of the function
        //The above function calculates similarity score for every pair of users
        //6.0 create a new function that prints out the contents of user_user_matrix 

        try
        {
            //fileinputstream just reads in raw bytes. 
            FileInputStream fstream = new FileInputStream("inputfile.txt");

            //because fstream is just bytes, and what we really need is characters, we need
            //to convert the bytes into characters. This is done by InputStreamReader. 
            BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
            int numberOfUsers=Integer.parseInt(br.readLine());
            int numberOfMovies=Integer.parseInt(br.readLine());

            //Now you have numberOfUsers and numberOfMovies to create your first object. 
            //this object will initialize the user_movie_matrix and user_user_matrix.

            new cfiltering(numberOfUsers, numberOfMovies);

            //this is a blankline being read
            br.readLine();
            String row;
            int userNo = 0;
            while ((row = br.readLine()) != null)   
            {
                //now lets read the matrix from the file
                String allRatings[]=row.split(" ");
                int movieNo = 0;
                for (String singleRating:allRatings)
                {
                    int rating=Integer.parseInt(singleRating);
                    //now you can start populating your user_movie_matrix
                    System.out.println(rating);
                    user_movie_matrix[userNo][movieNo]=rating;
                    ++ movieNo;
                }
                ++ userNo;
            }
        }
        catch(Exception e)
        {
            System.out.print(e.getMessage());
        }
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:42:05+00:00Added an answer on May 28, 2026 at 4:42 pm

    Try closing and reopening the file, then press Ctrl+F11.

    Verify that the name of the file you are running is the same as the name of the project you are working in, and that the name of the public class in that file is the same as the name of the project you are working in as well.

    Otherwise, restart Eclipse. Let me know if this solves the problem! Otherwise, comment, and I’ll try and help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can we have two main() functions in a C++ program?
Can anyone tell me how to open Auto CAD file in HTML5? Is this
can any one tell me how can change this java code into objective c.is
Can I run this in a Windows command prompt like I can run it
Can a LINQ enabled app run on a machine that only has the .NET
Can anyone recommend a good library for generating an audio file, such as mp3,
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
Can I call a java class method from inside a flash movie?
Can anyone give me an example of how to return the following json simply

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.