• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

"Hello World" execution error

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm just getting started with Java. I'm trying to run a "Hello" program. The code is:

class Hello {
public static void main(String[] args) {
System.out.println("Hello World!") ;
}
}

It compiles OK but when I run it with "java Hello", I get the following error-

Exception in thread "main" java.lang.UnsupportedClassVersionError: Hello <Unsupported major.minor version 49.0> at java.lang.ClassLoader.defineClass0<Native Method>
etc .....

Did I miss something in my java setup?

Thanks,

Mike
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mike,

Welcome to JavaRanch!

You've got multiple versions of Java installed, and the one you're using to compile the program is newer than the one you're using to run it; specifically, the compiler is JDK 1.5, and the runtime is JDK 1.4 or earlier.

Often when you install the Java plug-in for your Web browser, it will stick a copy of java.exe into your WINDOWS folder or someplace else early on your PATH. You have a number of options: uninstalling the plugin and installing a newer version is one; changing your PATH to put the JDK/bin directory first is another.
 
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're running on windows, you might want to use something like this "setjava.bat" script:


You could put it in your project directory, or in a global "utilities" directory.

You could use it as follows:

'Hope that helps .. PSM
[ December 04, 2005: Message edited by: Paul Santa Maria ]
 
Mike Angelastro
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Paul and Ernest!

With the help of both of you, I was able to figure it out. I had installed an Oracle demo on my machine and it had references to Java in the path. I moved them to the end of the path, after which my simple little app worked fine.

Thanks a bunch,

Mike
reply
    Bookmark Topic Watch Topic
  • New Topic