Convert .jar to an application for Windows, Linux & Mac

I made a Java application with Eclipse (exported in *.jar ), and I want to export it for Windows ( .exe ), Linux ( .? ) and MAC ( .? ). I don't own any Linux or MAC machine, so I don't know what extension file is required for each one. So I have several questions :

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

  • My application saves options into the Windows registry (I used the "JavaRegisrtyWrapper" library). Is there any "registry" equivalent for MAC and Linux (and how can I read/write informations there) ?

  • Is it possible to avoid the Windows alert "Unknown publisher" for users when they try to launch the *.exe file after the download ? (And will I have the same problem on MAC and Linux ?). I tried to create my own certificate, and to sign the file with "signtool.exe" but it didn't work.

  • Thanks !

    EDIT : Before converting the *.jar file into any other format, I have to modify my code to get user's 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 & Mac (if this folder exists...) ?


    Script which runs JAR application

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

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

    Windows registry equivalent on Unix-based systems

    There is no Windows registy equivalent on Linux and Mac Os. You can store your configuration in ie text files. Machine specific configs are typically stored in the /etc directory tree.

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

    Signing a Windows EXE files

    For signing Windows exe files you can try using Microsoft's Sign Tool.

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


    Linux does not neccessarly have an extension. Normally binary files just dont have one. To mark them as executable you set the +x flag on the file, which will grant the file the rights to be executed.

    OSX also does not neccessarly have an extension. If you want to install your Program on a Mac, it will be packaged in a folder (on mac these dont look like folders, they look like programs, but on other OSes these appear as folders) with the extension .app .

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

    The "alert" Problem is because your app is not signed. Signing an application means to seal it up so it cant be modified afterwards (it could be modified, but would break the seal). On OSX you can get a developers certificate and use codesign on the .app ( codesign -s "certname" with installed certificate). On Linux you will not have this problems as the programs normally dont get signed (the packages of a package manager normally get signed, this information is lost after installation).

    On Windows you also can buy a certificate. After doing so and signing your program, the "alert" might still come given the settings of a user, but it will show the developers or company name instead of unknown (unknown will only appear if not signed or a signed program has been modified after signing).


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

    or put this into a script file like: myscript.sh set execution permissions:

    > chmod ugo+x myscript
    

    example script:

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

    then run ./myscript.sh

    链接地址: http://www.djcxy.com/p/34960.html

    上一篇: 无法在Firebase控制台中创建新项目

    下一篇: 将.jar转换为适用于Windows,Linux和Mac的应用程序