Click to See Complete Forum and Search --> : A bunch of "Class" errors


abudabit
01-29-2005, 11:52 AM
I just installed JDK, and set the enviromental variables. Here is the test script I am running:


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


But when I run it: C:\robot>java myfirstjavaprog

I get this:

____________________________________________________________
C:\robot>java myfirstjavaprog
Exception in thread "main" java.lang.UnsupportedClassVersionError: myfirstjavaprog (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)

Khalid Ali
01-29-2005, 12:31 PM
there are different JVM versions installed on your machine, make sure that you have one.( more precisely a java file in path points to another version then some other versions on your machine)

once you have that then do the following
javac myfirstjavaprog.class

it should come back to the prompt then
java myfirstjavaprog
this should work this time around

abudabit
01-29-2005, 12:42 PM
It worked!

Thank you very much. Yeah, I had like two other versions of Java on there. :eek:

ray326
01-29-2005, 01:16 PM
Also your class names should be capitalized and camel-cased.

class MyFirstJavaProg ...