-1

I am using VSCode to create a Java GUI (that is connected to a SQL Server Database). Everything runs when I run it using VSCode's Java Project system, however, when I try to convert it to a jar file, I get this error:

Error: LinkageError occurred while loading main class App java.lang.UnsupportedClassVersionError: Preview features are not enabled for App (class file version 64.65535). Try running with '--enable-preview'

When I run it with --enable-preview, it works. However, I need to make it work permanently on the jar (when I double click)

App is the name of my 'Main' class

My current java version:

java -version
java version "20" 2023-03-21
Java(TM) SE Runtime Environment (build 20+36-2344)
Java HotSpot(TM) 64-Bit Server VM (build 20+36-2344, mixed mode, sharing)

Note: I am using a Mac and NO build tools (like Maven/Gradle etc.)

Any help is appreciated!

Reilas
  • 3,297
  • 2
  • 4
  • 17
  • What GUI library are you using? – Conor Egan May 23 '23 at 20:18
  • I'm using swing (jFrame, jTextArea etc.) – SpottableFir22 May 23 '23 at 20:23
  • I tried this, but got the same error – SpottableFir22 May 23 '23 at 20:30
  • Edit your Question to have those additional details. – Basil Bourque May 23 '23 at 22:59
  • By the way… Preview features are *not* meant to be deployed. Thus the label "preview". See https://openjdk.org/jeps/12 and https://docs.oracle.com/en/java/javase/20/language/preview-language-and-vm-features.html – Basil Bourque May 23 '23 at 23:01
  • Are you using a preview feature in your code? You might need to share the code, and the command used to compile. – matt May 24 '23 at 11:17
  • Maybe you can try using a IDE that is more towards Java developing. For example NetBeans, IntelliJ, Eclipse ,... . They have GUI builder-tools inside them. That makes problem solving a little bit easier. -> That's a more general answer. – Peter Mulm May 24 '23 at 12:20
  • It is working now. I just had to add a .settings file with org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled. However, my jar still won't open on double click only through command line – SpottableFir22 May 24 '23 at 12:22

1 Answers1

1

It is working now. I just had to add a .settings folder that contains a file with org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled.