2

I need to launch a Jar file with a portable JRE. It works on Windows thanks to launch4j, it works on Ubuntu thanks to me, but not on Mac ..... and I can't test it.

The path tree of application:

    abcmap/
          launcher.command
          bin/
              abcmap.jar
              jre/
                  bin/
                      java

Thinking it's like Unix system, I tried this (without specify bash):

./bin/jre/bin/java -Xms512m -Xmx1024m -jar ./bin/abcmap.jar

But this error appear:

    MacBook-Pro:~ frcstnt$ /Applications/abcmap-mac/abcmap.command; 
    exit;
    /Applications/abcmap-mac/abcmap.command: line 1:
    bin/jre/bin/java: No such file or directory
    logout

All files are rwx for all,
All files are UTF8 without BOM
I tried to change end of line to Unix and to "Old Mac" with Notepad++,

Archives are available on my website:
http://abc-map.fr/download/
https://translate.google.fr/translate?hl=fr&sl=fr&tl=en&u=http%3A%2F%2Fabc-map.fr%2F

Someone can help me please?

Edit: I think my problem is in the launcher, maybe encoding or bad command ?

Edit: Thanks to the Wim's answer it works. This is the script:

#!/bin/bash 
SCRIPTDIR=$(dirname $0) 
cd $SCRIPTDIR 
${SCRIPTDIR}/bin/jre/bin/java -jar ${SCRIPTDIR}/bin/abcmap.jar

3 Answers3

1

The path ./bin/jre/bin/java will be resolved relative to the current directory, not relative to the location of the command file. Try what happens if you run the command from the directory where the command is located.

Wim Deblauwe
  • 25,113
  • 20
  • 133
  • 211
  • I tried this and it works ! #!/bin/bash SCRIPTDIR=$(dirname $0) cd $SCRIPTDIR ${SCRIPTDIR}/bin/jre/bin/java -jar ${SCRIPTDIR}/bin/abcmap.jar – Rémi Passmoilesel Feb 05 '15 at 17:26
0

I think I've found thanks to Wim Deblauwe. I use this:

#!/bin/bash
SCRIPTDIR=$(dirname $0)
cd $SCRIPTDIR
${SCRIPTDIR}/bin/jre/bin/java -jar ${SCRIPTDIR}/bin/abcmap.jar

Find the script dir, go to this dir and start operations.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
  • I removed your follow-up question so that this answer won't be deleted as "not an answer". You can ask a new question, but I suggest, you should check yourself first. I also suggest, to [accept](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) Wim's answer as it goes more into detail. – Artjom B. Feb 05 '15 at 17:00
  • I've accepted Wims question and I will copy answer (script) in a comment. It was my first question so can you delete this message or make it "0" instead of "-1 ?" – Rémi Passmoilesel Feb 05 '15 at 17:26
-1

It seems like you maybe don't even have the Java Runtime Evironment installed. You should try running java -version or at least java -h or java --help.

If you output is something like the following:

java: command not found

You should download and install the latest JRE and try again.

If, however, you see your java version, try first using cd to go to the directory of your jarfile and then use:

java -jar -otheroptionshere jarfile.jar

I hope this helps! Tell me, if you still got issues.

Marco
  • 330
  • 3
  • 12
  • JRE is in the directory "./bin/jre/" so normally the program must work alone, without installing Java. I want make my app portable. My problem is in the launcher: find the good path to integrated JRE and give the goods args to launch the JAR file. Thanks for help. – Rémi Passmoilesel Feb 05 '15 at 08:53