Execute a jar with double click in linux












0















What I'm trying to achieve is to run a java program on any Linux system (Ubuntu, Fedora, etc... covering as much as possible) by simply double clicking a file-like I would on Windows.

I have created a .sh file(and granted execute permissions) with the following content:



#!/bin/sh
java -Xmx512M
-Djava.library.path="."
-DclientAppDataPath="Application Data"
-jar Client.jar
Phoenix.client.ClientMain
1>output.txt 2>error.txt


If I try to execute this file using the Ubuntu Terminal it works fine. However when I try to double click the file and choose Run or Run in Terminal, I see nothing. Apparently the shell opens and closes immediately. How do I avoid this?



EDIT:

I noticed error.txt contains:




blah/blah/blah/Client Launcher.sh: 2:
blah/blah/blah/Client Launcher.sh: java: not found




I have extracted a jdk1.x.x.tar.gz and added java home to PATH manually using .bashrc file. Could this be the cause? How can I fix it?










share|improve this question




















  • 2





    Try using the full path to java.

    – pjc50
    Sep 9 '13 at 14:20











  • @pjc50, Damn! It worked. That doesn't solve my problem in general (a setup program generates this file), but at least I'm sure of what's going on.

    – atoMerz
    Sep 9 '13 at 14:26













  • If you don't use a locally installed (i.e. not installed by the package management) version of java, your script does not know where it is located. .bashrc is only evaluated when you log into an interactive session.

    – Tim
    Sep 9 '13 at 14:30
















0















What I'm trying to achieve is to run a java program on any Linux system (Ubuntu, Fedora, etc... covering as much as possible) by simply double clicking a file-like I would on Windows.

I have created a .sh file(and granted execute permissions) with the following content:



#!/bin/sh
java -Xmx512M
-Djava.library.path="."
-DclientAppDataPath="Application Data"
-jar Client.jar
Phoenix.client.ClientMain
1>output.txt 2>error.txt


If I try to execute this file using the Ubuntu Terminal it works fine. However when I try to double click the file and choose Run or Run in Terminal, I see nothing. Apparently the shell opens and closes immediately. How do I avoid this?



EDIT:

I noticed error.txt contains:




blah/blah/blah/Client Launcher.sh: 2:
blah/blah/blah/Client Launcher.sh: java: not found




I have extracted a jdk1.x.x.tar.gz and added java home to PATH manually using .bashrc file. Could this be the cause? How can I fix it?










share|improve this question




















  • 2





    Try using the full path to java.

    – pjc50
    Sep 9 '13 at 14:20











  • @pjc50, Damn! It worked. That doesn't solve my problem in general (a setup program generates this file), but at least I'm sure of what's going on.

    – atoMerz
    Sep 9 '13 at 14:26













  • If you don't use a locally installed (i.e. not installed by the package management) version of java, your script does not know where it is located. .bashrc is only evaluated when you log into an interactive session.

    – Tim
    Sep 9 '13 at 14:30














0












0








0








What I'm trying to achieve is to run a java program on any Linux system (Ubuntu, Fedora, etc... covering as much as possible) by simply double clicking a file-like I would on Windows.

I have created a .sh file(and granted execute permissions) with the following content:



#!/bin/sh
java -Xmx512M
-Djava.library.path="."
-DclientAppDataPath="Application Data"
-jar Client.jar
Phoenix.client.ClientMain
1>output.txt 2>error.txt


If I try to execute this file using the Ubuntu Terminal it works fine. However when I try to double click the file and choose Run or Run in Terminal, I see nothing. Apparently the shell opens and closes immediately. How do I avoid this?



EDIT:

I noticed error.txt contains:




blah/blah/blah/Client Launcher.sh: 2:
blah/blah/blah/Client Launcher.sh: java: not found




I have extracted a jdk1.x.x.tar.gz and added java home to PATH manually using .bashrc file. Could this be the cause? How can I fix it?










share|improve this question
















What I'm trying to achieve is to run a java program on any Linux system (Ubuntu, Fedora, etc... covering as much as possible) by simply double clicking a file-like I would on Windows.

I have created a .sh file(and granted execute permissions) with the following content:



#!/bin/sh
java -Xmx512M
-Djava.library.path="."
-DclientAppDataPath="Application Data"
-jar Client.jar
Phoenix.client.ClientMain
1>output.txt 2>error.txt


If I try to execute this file using the Ubuntu Terminal it works fine. However when I try to double click the file and choose Run or Run in Terminal, I see nothing. Apparently the shell opens and closes immediately. How do I avoid this?



EDIT:

I noticed error.txt contains:




blah/blah/blah/Client Launcher.sh: 2:
blah/blah/blah/Client Launcher.sh: java: not found




I have extracted a jdk1.x.x.tar.gz and added java home to PATH manually using .bashrc file. Could this be the cause? How can I fix it?







linux java shell-script jar






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 9 '13 at 14:10







atoMerz

















asked Sep 9 '13 at 13:39









atoMerzatoMerz

2143613




2143613








  • 2





    Try using the full path to java.

    – pjc50
    Sep 9 '13 at 14:20











  • @pjc50, Damn! It worked. That doesn't solve my problem in general (a setup program generates this file), but at least I'm sure of what's going on.

    – atoMerz
    Sep 9 '13 at 14:26













  • If you don't use a locally installed (i.e. not installed by the package management) version of java, your script does not know where it is located. .bashrc is only evaluated when you log into an interactive session.

    – Tim
    Sep 9 '13 at 14:30














  • 2





    Try using the full path to java.

    – pjc50
    Sep 9 '13 at 14:20











  • @pjc50, Damn! It worked. That doesn't solve my problem in general (a setup program generates this file), but at least I'm sure of what's going on.

    – atoMerz
    Sep 9 '13 at 14:26













  • If you don't use a locally installed (i.e. not installed by the package management) version of java, your script does not know where it is located. .bashrc is only evaluated when you log into an interactive session.

    – Tim
    Sep 9 '13 at 14:30








2




2





Try using the full path to java.

– pjc50
Sep 9 '13 at 14:20





Try using the full path to java.

– pjc50
Sep 9 '13 at 14:20













@pjc50, Damn! It worked. That doesn't solve my problem in general (a setup program generates this file), but at least I'm sure of what's going on.

– atoMerz
Sep 9 '13 at 14:26







@pjc50, Damn! It worked. That doesn't solve my problem in general (a setup program generates this file), but at least I'm sure of what's going on.

– atoMerz
Sep 9 '13 at 14:26















If you don't use a locally installed (i.e. not installed by the package management) version of java, your script does not know where it is located. .bashrc is only evaluated when you log into an interactive session.

– Tim
Sep 9 '13 at 14:30





If you don't use a locally installed (i.e. not installed by the package management) version of java, your script does not know where it is located. .bashrc is only evaluated when you log into an interactive session.

– Tim
Sep 9 '13 at 14:30










1 Answer
1






active

oldest

votes


















0














There's a nice solution which causes Java jar files to be treated as an executable without requiring shell scripts, although it's a little fiddly to set up:



https://wiki.archlinux.org/index.php/Binfmt_misc_for_Java



I believe that popular distros have packages that will sort it out for you, although I've not used it myself recently.






share|improve this answer
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f642924%2fexecute-a-jar-with-double-click-in-linux%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    There's a nice solution which causes Java jar files to be treated as an executable without requiring shell scripts, although it's a little fiddly to set up:



    https://wiki.archlinux.org/index.php/Binfmt_misc_for_Java



    I believe that popular distros have packages that will sort it out for you, although I've not used it myself recently.






    share|improve this answer




























      0














      There's a nice solution which causes Java jar files to be treated as an executable without requiring shell scripts, although it's a little fiddly to set up:



      https://wiki.archlinux.org/index.php/Binfmt_misc_for_Java



      I believe that popular distros have packages that will sort it out for you, although I've not used it myself recently.






      share|improve this answer


























        0












        0








        0







        There's a nice solution which causes Java jar files to be treated as an executable without requiring shell scripts, although it's a little fiddly to set up:



        https://wiki.archlinux.org/index.php/Binfmt_misc_for_Java



        I believe that popular distros have packages that will sort it out for you, although I've not used it myself recently.






        share|improve this answer













        There's a nice solution which causes Java jar files to be treated as an executable without requiring shell scripts, although it's a little fiddly to set up:



        https://wiki.archlinux.org/index.php/Binfmt_misc_for_Java



        I believe that popular distros have packages that will sort it out for you, although I've not used it myself recently.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 9 '13 at 14:21









        pjc50pjc50

        5,6411826




        5,6411826






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f642924%2fexecute-a-jar-with-double-click-in-linux%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

            Mangá

             ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕