Search code examples
javavisual-studio-codejar

Linkage Error occurred while loading main class Try running with '--enable-preview'


I have issue with jar file . When ever I want to open it I have to write java --enable-preview -jar .jar.

I'm using Java 16.0.1

I'm not using Maven or anything else. I just created my java project in Visual Studio Code. I even tried javac -cp --enable-preview --release 16 src\filename.java src\packs*.java -d bin

to auto enable it at compile time.

Still it is showing : Linkage Error occurred while loading main class : Preview features are not enabled for (class file version 60.65535). Try running with '--enable-preview'.

Please Help me in this scenario. I cannot share my code as it is of more than 3.5 k lines


Solution

  • SO basically I had to create a .bat file with java --enable-preview -jar <filename>.jar

    this resolved my issue.