#Integrating "--enable-preview" console arg into my code

56 messages · Page 1 of 1 (latest)

ebon kettle
#

I am struggling with a small-ish Problem i ran into

Description:
Technically my code works, but nothing happened when i double clicked it (it is supposed to open a GUI, being a replicate of Snake).
Opened the console to start it manually and see what is wrong. Told me i should try to add --enable-preview. I did so and it properly launched. Then i made a 1-line .bat script to do that for me.

Issue:
Then I sent it (.jar and .bat) to a friend to see if it works for him aswell. It didnt, since he doesnt have Java installed on his PC and therefor the batch isnt able to use the Java commands.
I looked into ways to convert jar's into exe's, downloaded Launch4j and ran into the issue from earlier, it needs --enable-preview to run
Launch4j has a command args line to write smth in, played around with it but no success.

Steps i have taken:
Spent hours of researching, found a few things which could help. But sadly, nothing worked.
I looked at how Minecraft deals with that, since it is in Java and runs out-of-the-box.
They have the JDK folded integrated into the game.
while it is a solution, not really viable for me to put the JDK into a little Game that isnt even a Megabyte.

Tldr:
I need to have the --enable-preview arg in my code, because otherwise Launch4j throws an error and i wont be able to convert it.
Why would i like to convert it? I want to learn how to make a proper App run out-of-the-box for future users who would want to try out my programs.

I ran out of ideas, so that's why i came here to ask for help
Thanks in advance!

Edit: I am using the VS Studio IDE

potent flumeBOT
#

This post has been reserved for your question.

Hey @ebon kettle! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

ebon kettle
#

Project folder:

#

(also yes i know i am using javax.swing library, changed the libraries mid-through and didnt want to create yet another folder)

heady remnant
#

You cant run jar without java installed

ebon kettle
#

But either way, there should be a way to have the --enable-preview arg already in my code, so i wouldnt need a .bat to do for me.
Dont get me wrong, that isnt a big problem in any way, i am just interested in how these things work and how to solve nieche issues

heady remnant
#

so your problem is that you cant double click your jar?

ebon kettle
heady remnant
ebon kettle
#

(Unless i'm confusing languages and Java doesnt support that to begin with)

heady remnant
ebon kettle
heady remnant
#

also you are using java swing

heady remnant
ebon kettle
heady remnant
#

also i think you diddnt selected the App as the call from which you want to start

#

nvm

#

Which java version did you use to compile?

heady remnant
heady remnant
# heady remnant Which java version did you use to compile?

App has been compiled by a more recent version of the Java Runtime (class file version 63.65535), this version of the Java Runtime only recognizes class file versions up to 62.0

that means that you have compiled it with a more recent version as you are trying to open it with

ebon kettle
ebon kettle
# heady remnant

i have that the same
and with your OptiFine example, that works for me aswell, same as Launch4j (which both share the penguin icon)
but for my own .jar's it doesnt

heady remnant
#

in which java version are you coding?

#

or could you download my jar and try that?

heady remnant
ebon kettle
#

if you mean actual java, i could install a newer version rq

heady remnant
#

and could you go into cmd and type java -version

ebon kettle
#

last time i downloaded that was around a year ago

heady remnant
#

are you able to run my jar?

ebon kettle
#

i actually can

#

double-click works fine

heady remnant
#

could you share me your result?

ebon kettle
ebon kettle
heady remnant
#

could you do it with the enable preview?

ebon kettle
#

with EP it works yes

heady remnant
#

how did you compile your jar? which ide

ebon kettle
#

VS Code

#

with their Extension and external JDK

#

and from scratch, so no Maven/Gradle

heady remnant
#

could you switch to Intellij (its free and also has proberbly all the plugins you have now)

ebon kettle
#

i'll give it a try

#

probably i'll keep it for compiling xd

#

you exported my Project from IntelliJ if i may guess?

heady remnant
ebon kettle
#

thanks for the assistance

#

guess i'll have to look how to make it properly work with VSC aswell at some point, till then i will use intellij to build my projects