• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help! Error trying to run after JDK install

 
Brian Wieb
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Can anyone help with an error I'm getting trying to run a simple app? I have just installed jdk1.5.0_03

The error is "Exception in java "main" java.lang.UnsupportedClassVersionError: SimpleGui1 (Unsupported major.minor version 49.0)

The code is:
import javax.swing.*;

public class SimpleGui1 {
public static void main (String[] args) {
JFrame frame = new JFrame();
JButton button = new JButton("click me");

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.getContentPane().add(button);

frame.setSize(300,300);

frame.setVisible(true);
}
}

Thanks in advance !
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Brian,

Welcome to JavaRanch!

You've got more than one version of Java installed on your machine, which is perfectly OK -- but you have to keep them straight. You've compiled your classes with JDK 1.5, but are trying to run it with an older version.

You can either find the offending copy of Java (some older JDKs liked to put a copy of java.exe into C:\WINDOWS\ or some other such silly place) and delete it, or you can modify your PATH environment variable so that the JDK 1.5 installation location comes before the location of this older Java version. Whichever is easier for you.
 
Brian Wieb
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you ! Thank you !
Wow, I'm an old RPG programmer trying to learn JAVA for a new job. It's quite a culture shock for me with all this "newfangled" stuff.
I uninstalled the older version and it works fine. I was really stumped so your suggestion got me going again..for now...I may have to use this forum again. Thanks for the help !
Brian.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic