Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
772 views
in Technique[技术] by (71.8m points)

heroku - UnsupportedClassVersion Error after java update

Just 2-4 hours ago, i received an update to java on my laptop. and i installed it.

I am working on an java application for a month now. I upload this application on heroku server.

Before java update, (2-3 days ago) everything worked fine. But now when i upload the app and run it on heroku, it get this error :-

Exception in thread "main" java.lang.UnsupportedClassVersionError: MainClass has been compiled by a more recent version of the Java Runtime (class file version 58.0), this version of the Java Runtime only recognizes class file versions up to 52.0
2021-01-23T21:29:31.889016+00:00 app[worker.1]:     at java.lang.ClassLoader.defineClass1(Native Method)
2021-01-23T21:29:31.889087+00:00 app[worker.1]:     at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
2021-01-23T21:29:31.889208+00:00 app[worker.1]:     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
2021-01-23T21:29:31.889278+00:00 app[worker.1]:     at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
2021-01-23T21:29:31.889361+00:00 app[worker.1]:     at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
2021-01-23T21:29:31.889464+00:00 app[worker.1]:     at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
2021-01-23T21:29:31.889589+00:00 app[worker.1]:     at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
2021-01-23T21:29:31.889665+00:00 app[worker.1]:     at java.security.AccessController.doPrivileged(Native Method)
2021-01-23T21:29:31.889746+00:00 app[worker.1]:     at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
2021-01-23T21:29:31.889852+00:00 app[worker.1]:     at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
2021-01-23T21:29:31.889922+00:00 app[worker.1]:     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
2021-01-23T21:29:31.890074+00:00 app[worker.1]:     at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
2021-01-23T21:29:31.890142+00:00 app[worker.1]:     at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)

I am using IntelliJ Idea.

Everytime, I choose default setting and by default, Idea picks up all the latest files that i have.

I think the issue is because i now need to compile the code using a lower version of Java? Can someone tell me how to fix this problem ?

After updating java to Java SE 15

question from:https://stackoverflow.com/questions/65864771/unsupportedclassversion-error-after-java-update

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You don't see two "version series." What you see is only a change in the way they name Java versions. Java 8 is effectively the same as Java 1.8.

Heroku supports Java 7, 8, 11, 13 and 15. Since you're using Java 14, you're compiling against a version of Java that Heroku does not support. Reinstall any version of Java that Heroku actually supports and you should be fine.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...