Home > OS >  Exporting jar file from vscode, The jar file does not open
Exporting jar file from vscode, The jar file does not open

Time:01-13

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'"
    

CodePudding user response:

Preview features are enabled by default. Configure the java.configuration.runtimes preference in your User Settings.json:

"java.configuration.runtimes": [
  {
    "name": "JavaSE-17",
    "path": "/path/to/jdk-17",
    "default": true
  },
],

Then reload window and try again.

Reference: Enabling Java preview features

CodePudding user response:

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

  •  Tags:  
  • Related