0
votes

I have been facing this simple issue yet not able to fix this. Getting this error both in eclipse as well as while running from command prompt.

This question is asked many times here I know, but didn't quiet get the solutions from any of those.

Just trying to understand things. Here is this simple to try program which I have.

package com;

public class Test {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println("Hellooooooo");
    }

}

In eclipse I get this Error: Could not find or load main class com.Test

Now when I try from command Prompt.

C:\workSpaceLatest\Test\src\com>java Test
Error: Could not find or load main class Test

When I run C:\workSpaceLatest\Test\src\com>javac Test.java no Error also no Output

enter image description here

But in IntelliIDEA it works fine. why is it so. Someone help me understand this for once.

**P.S : Point me to any posts or questions which has best answer. I haven't found any though.

1

1 Answers

1
votes

Since you have com as package the class name will be com.Test so to run the class run is from C:\workSpaceLatest\Test\src folder as follows after compilation.

C:\workSpaceLatest\Test\src>java com.Test

enter image description here

Note: You can compile the class as you do now.