1

sorry if this question was repeated earlier, but I couldnt seem to find the answer. I have a code:

import java.util.Scanner;
public class PracticeProblems {
    public static void main(String[] args) {
        int x;
        Scanner input = new Scanner(System.in);
        System.out.println("Enter a number: ");
        x= input.nextInt();
        if(x%2 == 0) {
            System.out.println(x%2==0); 
        }
        else {
            System.out.println(x%2==0);
        }


    }

}

Now I am not too worried if the code actually works or not (because this same problem has occurred when the code was perfectly functional) I am just as confused why it doesnt run. ERROR BOX

desiigner
  • 89
  • 1
  • 3
  • 10
  • 1
    look closely at the error msg in the img. in __Java__ class name should be same as filename.java i.e PracticeProblem == ComputeArea – roottraveller Feb 01 '18 at 14:33
  • @roottraveller The filename is already the same as the class name. What that red message tells us is something different: OP runs an outdated run configuration. – Tom Feb 01 '18 at 14:39
  • Did you notice the error message in the console? It is very clear about what is wrong. Concerning the empty error box, you should file an issue in the Eclipse bug tracker: https://bugs.eclipse.org/bugs/ – user1438038 Feb 01 '18 at 14:45
  • Possible duplicate of [Eclipse shows empty error message with Java 9](https://stackoverflow.com/questions/45907867/eclipse-shows-empty-error-message-with-java-9) – user1438038 Feb 01 '18 at 14:48

3 Answers3

1

Try running by right clicking on PracticeProblems.java, and choosing "Run As Application". It looks like it is trying to run ComputeArea, and can't find that class.

Dave Drake
  • 323
  • 2
  • 12
  • i was trying to run all of my programs to see if any run but the same error message appears – desiigner Feb 01 '18 at 14:39
  • Then I would suspect eclipse is in a bad state. You can try closing your project and re-opening it, or restarting eclipse. If that doesn't work, create a new workspace and recreate the project. – Dave Drake Feb 01 '18 at 14:42
1

I had a similar problems too.

  1. Eclipse > Projects > Clean
  2. if its not working try to copy the class. Delete the Project and recreate it
Niton
  • 189
  • 4
  • 16
0

I have faced similar problems many times.

To solve this problem save the program, close Eclipse, reopen it and run the program without any loss of the program.

It works fine.

petezurich
  • 9,280
  • 9
  • 43
  • 57