Problem running program on other computers
I am using NetBeans to write beginning Java programs. Sometimes my program will run at home, but when I try to run the same program at school, I get a series of error messages, usually of this form:
run:
java.lang.UnsupportedClassVersionError: shapebase/Project : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader. java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java :615)
at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader .java:283)
at java.net.URLClassLoader.access$000(URLClassLoader. java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 47)
Could not find the main class: shapebase.Project. Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Of course the messages vary some due to different class names, etc, but they are essentially the same. Further more, if I create a new project on the second computer and copy the code into it, it works fine. What is probably causing this problem? Hopefully it is something simple I am neglecting!
Thanks!
Re: Problem running program on other computers
A quick google search will give you your answer, its to do with the JDK you use to compile the program.
Re: Problem running program on other computers
Quote:
Originally Posted by
wdh321
A quick google search will give you your answer, its to do with the JDK you use to compile the program.
Nope, it's just different versions of the Java virtual machine.
kind regards,
Jos
Re: Problem running program on other computers
Quote:
Originally Posted by
wdh321
A quick google search will give you your answer, its to do with the JDK you use to compile the program.
How can Java claim portability if one has to be careful of matching JDKs or JVMs when going from one machine to another and not get such a problem? This confuses me! This question probably really proves I am a beginner!
Re: Problem running program on other computers
Quote:
Originally Posted by
JosAH
Nope, it's just different versions of the Java virtual machine.
kind regards,
Jos
Sorry JVM, the correct answer pops up in the search though:)
Re: Problem running program on other computers
It's the JDK that sets the version in the class file. A younger version JRE can run a class file from an older version of the JDK/javac command.
Quote:
one has to be careful of matching JDKs or JVMs
That's a problem for a lot of software and hardware. Backward compatibility has been a headache for decades. Newer features are not known by older versions of software. My wife works with multiple versions of MS Word and has cussed out the people that insist on using the newest versions many times.
Re: Problem running program on other computers
Quote:
Originally Posted by
cccgsmith
How can Java claim portability if one has to be careful of matching JDKs or JVMs when going from one machine to another and not get such a problem? This confuses me! This question probably really proves I am a beginner!
No, it proves you don't really understand the concept of portability.
Learn your IDE. NetBeans has a per-project setting for the Java version for which it compiles your sources.
db