Convert .jar to application for Windows, Linux and Mac

I created a Java application with Eclipse (exported to *. Jar ) and I want to export it for Windows ( .exe ), Linux ( . ) And MAC ( .? ). I don’t own a Linux or MAC machine, so I don’t know which extension file is required for each of them. So I have a few questions:

  • For Windows, I used Launch4j to create my * .exe file, but is there an equivalent for MAC and Linux?

  • My application saves the settings in the Windows registry (I used the JavaRegisrtyWrapper library). Is there any equivalent of a “registry” for MAC and Linux (and how can I read / write information there)?

  • Is it possible to avoid the Windows “Unknown Publisher” warning for users when they try to run a * .exe file after loading? (And will I have the same problem on MAC and Linux?). I tried to create my own certificate and sign the file using "signtool.exe", but it did not work.

Thanks!

EDIT: before converting the * .jar file to any other format, I have to change my code in order to get the user OS, and the “documents” folder for each case. I think os.name can satisfy the first request, but can I use user.home + "Documents" for Windows, Linux and Mac (if this folder exists ...)?

+7
java linux windows executable macos
source share
3 answers

Script that runs the JAR application

On Linux and Mac OS, you can create a bash script that runs the .jar file:

#!/bin/bash java -jar application.jar

Windows registry equivalent on Unix based systems

There is no Windows equivalent for Linux and Mac Os. You can save your configuration in text files. Specific computer configurations are usually stored in the / etc directory tree.

Here is a similar superuser question: https://superuser.com/questions/295635/linux-equivalent-of-windows-registry

Signing Windows EXE files

You can try using the Microsoft Sign Tool to sign Windows exe files.

Here is a similar stackoverflow question: Signing a Windows EXE file

+3
source share

Linux has no extension. Usually binary files simply do not have. To mark them as executable, you set the + x flag in the file, which will grant the file permission to execute.

OSX also has no extension. If you want to install your program on a Mac, it will be packed into a folder (on a Mac they are not like folders, they look like programs, and on other OSs they look like folders) with the .app extension.

Launch4j can generate you binaries for all platforms, Mac OSX, Linux and Windows.

The “warning” problem is that your application is not signed. Signing an application means sealing it so that it does not subsequently be modified (it could have been modified, but the seal has been broken). On OSX, you can get a developer certificate and use codesign on .app ( codesign -s "certname" with the certificate installed). On Linux, you will not have such problems, because programs usually do not sign (package manager packages usually sign, this information is lost after installation).

On Windows, you can also buy a certificate. After this and signing your program, a “warning” can still appear, taking into account the user's settings, but it will show the developers or the name of the company, but not unknown (it will not appear if it is not signed, or the signed program was changed after signing).

0
source share

just run it: java -jar [your jar file]

or put this in a script file, for example: myscript.sh set execution permissions:

 > chmod ugo+x myscript 

example script:

 #!/bin/bash $JAVA_HOME/bin/java -jar [jarfile] 

then run. / myscript.sh

0
source share

All Articles