It's UWAweek 26 (mid-year break)

help2005

This forum is provided to promote discussion amongst students enrolled in CITS2005 Object Oriented Programming.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

How do I ask a good question?
Displaying selected article
Showing 1 of 257 articles.
Currently 9 other people reading this forum.


 UWA week 20 (1st semester, week 11) ↓
SVG not supported

Login to reply

👍?
helpful
11:12am Fri 17th May, Andrew G.

ANONYMOUS wrote:

Exception in thread "main" java.lang.UnsupportedClassVersionError: test/studentstats/StudentListIteratorTest has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 55.0 at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1022) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527) at test.studentstats.Test.run(Test.java:11) at test.Test.run(Test.java:14) at test.Test.main(Test.java:5)


Hi, I'm getting this error message since I've changed workspace from VS Code to Eclipse 2 days ago. I can compile but can't run it on wsl terminal. I've tried to several things such as installing lower version and re-install java, but both don't work. The only way I can run is deleting all .class files, but I'm afraid of the situation that it doesn't work at all while marking it, and it makes me bit annoying that I should delete all class files every single time I want to run my code. Could you please advise me to solve this error? Thank you in advance.

As the error says, you are attempting to run code that was compiled with a more recent version of the compiler, and so has produced class files that the older runtime can't support.

Firstly, this should not cause any issues with your submission, as remember that you are to submit only Java source code, not your class files. We will compile your code ourselves. So long as your code is valid Java 13, that shouldn't matter.

I can't provide tech support for your choice of IDE, as I am not familiar with Eclipse. The instructions I have provided say how to compile and run from the command line, which is always an option for you as well. Nothing in this project requires you to use an IDE.

Your IDE should be using matched versions of compiler and runtime, unless you have configured it to do otherwise. Are you sure you need to delete the class files every time? It would make sense after switching IDE to have class files around that were compiled using whatever compiler version VS Code was using, but once you delete them all and recompile, it should be whatever Eclipse is using, and there should be no need to delete them again.

You say you can compile but can't run in WSL. Are you compiling in Eclipse? Eclipse may be using a different JDK version to what you have in WSL. Eclipse should tell you somewhere what versions it is using, and you can find out in WSL by running javac --version and java --version.

With the above information you should hopefully be able to figure this out. Unless you have done something very strange, the versions in WSL for javac and java should be matched, so you can always just compile and run on the command line if you can't figure out Eclipse.

Gozz

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  5:07AM Sep 06 2023
Privacy policy