0
class Test {
    public static void main(String args[])
    {
        Boolean expr = true;
        if (expr)
        {
            System.out.println("true");
        }
        else
        {
            System.out.println("false");
        }
    }
}

EDIT:
the error is java.lang.UnsupportedClassVersionError

4
  • sorry but if you dont take the time to format this we dont want to take the time to answer it Commented Jul 12, 2011 at 7:26
  • You are missing a curly bracket? Commented Jul 12, 2011 at 7:27
  • There is no runtime error, only two syntax error and a typo. What error, anyway? Describe it if you want us to help. Commented Jul 12, 2011 at 7:28
  • You need to close class Tes wih } at the end of the code, plus I think you meant to name the class as Test with Tes but missed a t like I missed a t in the first with of my sentence.My missing t is not important but yours will be. Commented Jul 12, 2011 at 7:30

6 Answers 6

4

Static should be with lower case: static.

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

1 Comment

:yeah sry actually that is my typing mistake.still it is giving runtime error why?
2

Check this link

java.lang.UnsupportedClassVersionError: why is it thrown & how to resolve?

How to resolve UnsupportedClassVersionError?

Whenever you encounter this error, do check if you’re using an earlier version of JVM to execute the class file than the corresponding version of compiler you used to compile the source code. The example shown here was compiled using Java 5.0 compiler, but when I tried to run using JVM 1.4, I got the above error. I just needed to switch either to a JVM version 5.0 or above OR needed to switch to a Java Compiler of JDK 1.4 or below (you of course need to make sure the source code is compatible with the corresponding version of the compiler otherwise you’ll start getting other compiler errors).

A higher JVM version doesn’t cause a problem in most of cases unless the class file format is quite old (and hence doesn’t lie in the supported range as specified by Sun for that particular JVM version ... as discussed above). But, it’s always a good practice to have both the Compiler and the JVM of the same version.

3 Comments

where should i check the JVM version?
type java -version on terminal window. How to check the JVM available on a computer ?
i checked JVM in lib folder of JDk
1

This is no runtime error. This doesn't compile.

Use static (lowercase s) instead of Static.

2 Comments

Some IDE's still create a .class even if there are compile errors in the code. The error part is substituted by an Exception.
Yes, that's true, but I feel that labeling it as a compilation issue is more appropriate here. At least it was, question has been changed in the meanwhile.
1

static should be lower case, and I believe you need it to be a public class. Also why are you using Boolean instead of boolean, wrapper types aren't necessary here.

12 Comments

she is new obviously, I used String not string when I started C# because I didn't know there is a string besides String.
static is in lowercase..actually that is my typing mistake,why it is giving runtime error
I did the same but types are usually lower case.
what is the runtime error then you're not giving us any information?
I believe it should be public class Test in a file called Test.java if not you will get a runtime error, everything else is valid
|
1

This code (if using JDK 5 and upwards, because of autoboxing/unboxing) runs perfectly without any RuntimeException and it will display true on the console.

1 Comment

@krishna bhargavi, is the the full code or did you just paste partial code?
1

I think you are compiling with one version of java and running with another. To be clearer you are compiling with a later version of java and running with an earlier version.

Are you compiling and running this class in an IDE?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.