I have looked around but I cannot find anything that will help or work. I know there is Launch4j which will do what I want with an .exe but not a .app file. I have the runnable JAR but do not know how to bundle it into a .app. I have tried multiple times (with no success) to export it as a .app from eclipse but it will not open after it is exported; no error message it just will not open. So my question is how can I bundle this into an Application Bundle?
If you have Java 6 or lower and an older System, then you have a Program made by Apple (I think) in the Developer directory. This does exactly what you want, otherwise, you could create a "hack" Application bundle (because it's the "I don't want to search through the internet" method).
create a new file with the same name and paste the following code into it:
#!/bin/bash SOURCE="${BASH_SOURCE[0]}" while [ -h "$SOURCE" ]; do DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" SOURCE="$(readlink "$SOURCE")" [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" done DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" cd "$DIR" cd .. echo "$(pwd)" for file in * do if [ -f "$file" ] then if [[ "$file" =~ .*.jar ]] then java -jar "$file" fi fi done
save the file
chmod 755
note the space behind the 755. Then drag the file you just created into the Terminal window at the end of the text you just typed and hit enter. Note: You are creating a Default AppleScript Applet and then switch the executable with your own in order to be able to launch the jar file. To give it execute permission you need to do the chmod 755
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.