It's not a secret anymore!
The moose likes Beginning Java and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception in thread "main" java. lang. UnsupportedClassVersion Error: " Watch "Exception in thread "main" java. lang. UnsupportedClassVersion Error: " New topic

Exception in thread "main" java. lang. UnsupportedClassVersion Error:

eric scott

Joined: Jan 27, 2005
Posts: 2
I compile my application, but when I run the application I get this message,"

C:\>java Ch2Birthdate
Exception in thread "main" java.lang.UnsupportedClassVersionError: Ch2Birthdate
(Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at Source)
at Source)
at$100(Unknown Source)
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)


Now here is my code for the application

import javax.swing.*;
import java.util.*;
import java.text.*;

class Ch2Birthdate{

public static void main(String [] args){

String Input;

SimpleDateFormat sdf;

Input = JOptionPane.showInputDialog(null, "What is your birthdate?");
java.util.Date bdate = java.sql.Date.valueOf(Input);

sdf = new SimpleDateFormat("EEEE");

JOptionPane.showMessageDialog(null, "The day of your Birthday is: " + sdf.format(bdate));


Any advice is ok, thanks.
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

possible reasons -
1. u have 2 versions of jdk in ur path
2. You compiled using one version of jdk and try to run the program using some other version.

eric scott

Joined: Jan 27, 2005
Posts: 2
ram, thanks for the advice.
I checked my path, and there was other things in there.
So I cut everything out except C:\Program Files\Java\jdk1.5.0_01\bin.
I tried to run the application again, and I got the same error.

Next, I checked my java runtime settings. The path for user is
"C:\Program Files\Java\jre1.5.0-01\bin\javaw.exe",
The path for the system is the exact same.

I also have oracle, and jre1.4 installed on my computer if this matters.

Your advice is appreciated,
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Perhaps try running both javac and java by specifying the full path to both to make absolutely sure you know which is running. Also, you can do "java -version" and "javac -version" (two dashes? I don't ermember).

On a side note, you should get into the habit of always specifying a package for every class. The first non-comment/blank line should beYou'll need to create a directory structure that matches it and put your source file into it. You still issue your compile/run commands from the directory that contains the root package.

Since you're doing this in the root of your C drive, let's use "test" as the package. Create c:\test and put into it. Addto the top of the file. Then compile and run usingI don't think that's the issue here, but it's still a good practice. For one thing, you cannot import a class that's ni the default package.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
Remove java.exe and javaw.exe from your windows installation directories.
Not all JVM installers properly update those under all conditions, leading old versions to be used when trying to execute Java programs.
But as there's no javac.exe there that one will get called from the directory you installed the JDK to.

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Despite the error message having the word "thread" in it, this is not a thread-related problem. I'm moving this post to our Java beginner's forum.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Exception in thread "main" java. lang. UnsupportedClassVersion Error:
jQuery in Action, 3rd edition