Q:

Basic java program not compiling using command line

package test 
    public class test{
        public static void main (String args[]) throws Exception{

            System.out.println("testing");
       }
     }

I compile with the following command
javac test.java  -Xlint -g

I execute with the following command
java test 

Which gives me the error

Error: Could not find or load main class test

Now I strongly suspect something weird is going on with my java as eclipse is also crashing whatever I do. 

A:

I have copied your code and executed it using the same commands as you have specified, and it displays 'testing' as the output. 
By any chance, Is the class 'test'  in a package? 
If so, you can compile it successfully by entering into the package directory and then running the compile command but it gives an error while you run it from that directory. You gotta come one level up the directory and run the class.
Eg: if the test.java is in package called abc, then you could go to 'c:\example\abc\' where c:\example is an directory assumed, and compile it and it would compile just fine.
But for running it, you gotta go one level up the directory and run. So you got to go to c:\example\ and then run like this 'java abc.test'

