Search code examples
javavisual-studio-codejarvscode-extensionsexecutable-jar

Exporting jar file from vscode, The jar file does not open


If I Exported a file jar from IntelliJ and opened it work perfectly but if do this in vscode after exporting the file with no errors I can't open the file I click on the jar file and nothing happening ,I extract the both files jar the one from IntelliJ and the vscode one ( to look at the files in side jar file ) both had the same files and same MANIFEST.MF file so why the IntelliJ work but vscode one doesn't ?

NOTES:

  1. java -version: "17.0.1" and javac -version: 17.0.1 (no problem with versions).

  2. If I tried to open jar file with terminal not by clicking I got this Error:

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

Solution

  • The best way I found is by creating a .bat file and write this code in it : java --enable-preview -jar <filename>.jar now you can run the .jar file by running the generated .bat file