1

I'm trying to compile my programs using the command prompt on Windows 7. I'm having a problem when I during compile. I created a test program:

class test
{
    public static void main (String args[])
    {
        System.out.println("this is working!!!!!!");
    }
}

I use the following instructions from the command line:

cd \ 
cd summer
Javac test.java 
java test

I have even tried using javaw and I get the same message but in a pop-up box

Could not find the main class, program will exit.

image

Any suggestions?

4
  • 1
    Looks like you have a JRE installed that has an older version than the JDK you have. Make sure your "java.exe" comes from the same installation as your "javac.exe". Commented Aug 10, 2012 at 4:54
  • @BhavikAmban i am trying to compile test.java but i get the "message could not find the main class" Commented Aug 10, 2012 at 4:55
  • 1
    Can you edit your question with the results of running java -version and javac -version? Commented Aug 10, 2012 at 4:57
  • ive managed to solve the problem. Thanks. Commented Aug 10, 2012 at 5:36

2 Answers 2

5

It seems your JDK and JVM have different editions.

Sign up to request clarification or add additional context in comments.

5 Comments

This should be comment rather then an answer.
He doesn't have enough rep to comment.
@SenthilKumar that's not an excuse to abuse the answering system. That said, this isn't a terrible answer. It's not great, but it's only been three minutes.
It's an answer. I don't know why it is regarded as a comment.
This is an answer. How much more could he elaborate this point?
0

You are using different versions of JDK. Check the versions on your javac vs java. This error is telling you that your java and compiled class are not same versions. Check your path for configuration, type "set" in dos to see details.

Example: If you compiled your class with javac (version 7) and execute it with java (version 6)

1 Comment

Compiling with 6 and running with 7 should work. The other way around (compiling with 7, running with 6) does not. That's probably what's happening in this case.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.