| Author |
"Hello World" execution error
|
Mike Angelastro
Greenhorn
Joined: Dec 04, 2005
Posts: 2
|
|
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
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24081
|
|
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.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Paul Santa Maria
Ranch Hand
Joined: Feb 24, 2004
Posts: 236
|
|
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 ]
|
Paul M. Santa Maria, SCJP
|
 |
Mike Angelastro
Greenhorn
Joined: Dec 04, 2005
Posts: 2
|
|
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
|
 |
 |
|
|
subject: "Hello World" execution error
|
|
|