Double click .jar file execution

I use Eclipse as my Java IDE, and today I had an interesting problem. I used the built-in file> export> runnable jar file to create a jar file for one of my programs. It works fine if I run it from the command line / using a batch file, but it does not start with a double click. I am absolutely sure that the .jar files are associated with javaw and still not working. This is not a huge problem that I NEED to fix, but if anyone has ideas, I would like to hear them.

Update: I tried using Aram Kocharyan's solution (see answer below). Bad luck. This seems to be just one .jar file. All other jars are launched with a double click. Bank recovery does not help .: P

+4
source share
3 answers

I wrote a short guide on this subject that may help you:

http://ak.net84.net/projects/how-to-make-a-multi-platform-executable-java-jar-file/

This will work when double-clicking in windows without setting any additional settings, and I tested it with Jar Launcher on Mac and it does not complain.

+2
source

open your jar with. javaw
which is located in the bin jre folder ... on my computer it's @

 C:\Program Files\Java\jre\bin\javaw.exe 
0
source

Put this inside .bat:

 start javaw -classpath "%~dp0YOU-JAR-NAME.jar" -Djava.library.path="native" foo.package.bar.YourClassWithMainMethod 

the -Djava.library.path="native" parameter is not required to run it, I turn it on because one of the reasons for using .bat is to double-click on .jar instead to use the JVM parameters, in my case I need this parameter for my project run.

part% ~ dp0 gets the current directory

-one
source

Source: https://habr.com/ru/post/1394542/


All Articles