2

I recently finished a project in Eclipse and it ran without a problem. Then recently I imported a new assignment to work on for class, but when I did my old project all of a sudden had a x on its icon. I looked through the code, nothing had been changed, but it threw this error in the console:

java.lang.UnsupportedClassVersionError at java.lang.ClassLoader.defineClass1(Native Method) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:685)

And others. Is this possibly due to the version of java being used or something else?

2

1 Answer 1

0

An UnsupportedClassVersionError is thrown when you use a higher JDK version to compile than when you try to run the program. For example, you compile Program.java using JDK1.7 but then attempt to run using JDK1.6. I am guessing that upon importing the new assignment for your class, you unknowingly adopted to use the JDK that the imported project was compiled in.

I suggest going to Eclipse Preferences and taking a look at your installed JRE's to make sure everything is okay and also to look at the projects Properties and looking at its Build Path. In general, make you you are using a version to run in that is at LEAST what you used to compile it. If you chose a higher version everything will still be okay.

EDIT: Here is a link for more information on the matter and where I had originally read about this. I knew I had saved the link somewhere. http://javarevisited.blogspot.com/2011/07/javalangunsupportedclassversionerror.html

Sign up to request clarification or add additional context in comments.

2 Comments

I did have the wrong JDK uploaded for the project. I changed to the correct one for the Compile and Build Path, and it runs now, thanks!
No problemo at all. Glad I could help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.