Launching JAR-Archive using Shell-Script - Linux

This is a discussion on Launching JAR-Archive using Shell-Script - Linux ; Hi, I 'd be very thankfull if somebody could help me on this problem: I'm trying to write a launcher for a Java-App (bundled in a jar-File) using the following approach: #!/bin/sh set -xv x=\"${2}/bib/tagger.jar\"" installLinux "$1" "$2 java -jar ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Launching JAR-Archive using Shell-Script

  1. Launching JAR-Archive using Shell-Script

    Hi,

    I 'd be very thankfull if somebody could help me on this problem:

    I'm trying to write a launcher for a Java-App (bundled in a jar-File)
    using
    the following approach:


    #!/bin/sh

    set -xv
    x=\"${2}/bib/tagger.jar\"" installLinux "$1" "$2
    java -jar ${x}


    The script takes 2 parameters which are both passed through to the app
    (in addition to a third constant string); the second param indicates the
    absolute path (possibly containing spaces!!) to the installation
    directory, which contains a directory named "bib" where the jar-File
    (tagger.jar) is stored.

    Unfortunately it doesn't work, as the output shows:

    faui8s6 linuxtagger/tag ger> ./install.sh 512m
    "/home/sistbien/linuxtagger/tag ger"

    x=\"${2}/bib/tagger.jar\"" installLinux "$1" "$2
    + x='"/home/sistbien/linuxtagger/tag ger/bib/tagger.jar" installLinux
    512m /home/sistbien/linuxtagger/tag ger'

    java -jar ${x}
    + java -jar '"/home/sistbien/linuxtagger/tag' 'ger/bib/tagger.jar"'
    installLinux 512m /home/sistbien/linuxtagger/tag ger

    Unable to access jarfile "/home/sistbien/linuxtagger/tag


    The string assigned to x seems to be just fine, but the problem is that
    strange splitting of the path at the space position during the expansion
    of the "java"-call, resulting in the error! How can I work around this
    (it really seems to be an unlogical behavior)?

    Thanks for any help, it's really urgent!

    Greetings, Stefan


  2. Re: Launching JAR-Archive using Shell-Script

    stefanbienk@onlinehome.de (Bienk) writes:
    > #!/bin/sh
    > set -xv
    > x=\"${2}/bib/tagger.jar\"" installLinux "$1" "$2
    > java -jar ${x}
    > [...]
    > The string assigned to x seems to be just fine, but the problem is that
    > strange splitting of the path at the space position during the expansion
    > of the "java"-call, resulting in the error! How can I work around this
    > (it really seems to be an unlogical behavior)?


    You could use lists:

    x=( "${2}/bib/tagger.jar" "installLinux" "$1" "$2" )
    java -jar "${x[@]}"

    --
    __Pascal Bourguignon__ http://www.informatimago.com/

    "This machine is a piece of GAGH! I need dual Opteron 850
    processors if I am to do battle with this code!"

+ Reply to Thread