java 5 intro
843810Oct 13 2004 — edited Feb 15 2006I'm new to Java--I downloaded this today and started with the beginning example from a book. I was able to get the compiler javac to find the file--just a path problem. But gettting java to execute the .class file is giving me fits. I believe that a lot of people are having this problem (seems to be on a lot of forums), but I haven't seen a confirmed solution.
Basically, when executing java, I get an "Exception in thread main" error. I fooled around and discovered that this is the error thrown when I type in the name of a class that doesn't exist (eg, 'java bs' returns same error). After reading the forums, I tried setting the classpath. Here is a copy and paste of the output--basically the same, but perhaps more clues:
C:\Documents and Settings\Dan\Desktop\Java Dev>java -cp . Example
Exception in thread "main" java.lang.UnsupportedClassVersionError: Example (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.Secureg.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown 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)
Any ideas? Here's the code:
/*
This is a simple Java program.
Call this file Example.java.
*/
class Example {
// A Java program begins with a call to main()
public static void main(String[] args) {
System.out.println("Java drives the Web.");
}
}
I'd appreciate help!