Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a .jar with --enable-preview option

I am trying to run a .jar that was complied by intellij with preview features in java 14.

I am now trying to run the .jar on a server with java 14.

Error: LinkageError occurred while loading main class com.wickedstacks.agenda.AgendaRestApp
        java.lang.UnsupportedClassVersionError: Preview features are not enabled for com/wickedstacks/agenda/AgendaRestApp (class file version 58.65535). Try running with '--enable-preview'

What is the correct way to enable preview features at runtime?

java -jar agenda/agenda-rest-1.0.1.jar

gives the above error

java -jar agenda/agenda-rest-1.0.1.jar --enable-preview 

This would make sense but does nothing

java --enable-preview [app]

I dont understand this, how do i provide the app when the main class is in a .jar?

like image 979
jpell Avatar asked Sep 19 '25 00:09

jpell


1 Answers

any arguments listed after the jar/class-to-run are args for the app, not args for the VM. So, put those things in front.

java --enable-preview -jar agenda/agenda-rest-1.0.1.jar

or

java --enable-preview -cp lib1.jar:lib2.jar:. com.foo.MainClass
like image 192
rzwitserloot Avatar answered Sep 21 '25 18:09

rzwitserloot