Packaging Jar file for Mac and Windows without JRE bundled
up vote
4
down vote
favorite
I built in IntelliJ IDEA my javaFX application as jar file.
Using "Project Structure >> Artifacts >> + JavaFX Application" I can build .app, .dmg, .pkg, .exe with JRE included.
But I need build same files without JRE bundled.
Sure, I can use JAR, but I want to make my own icon and maybe installer.
I also tried to create .app folder from jar to execute it manually "java -jar myJarName.jar" , but if I have several JDK version - it always uses the latest (JRE 11) which not included javaFX library and my .app doesn't work. But if I run the same JAR with Jar Launcher.app it works perfectly. Somehow it chooses the right jre version.
ExcelsiorJet, install4j and similar apps work well, but my project is OpenSource and I can not pay 3000$ for this.
The question is - how can I build MacOs/Windows native launcher app/dmg/pkg/exe without JRE bundled for users who already have JRE installed? Can I use IntelliJ IDEA to build this a way as I built with jre bundled?
java bash javafx jar
add a comment |
up vote
4
down vote
favorite
I built in IntelliJ IDEA my javaFX application as jar file.
Using "Project Structure >> Artifacts >> + JavaFX Application" I can build .app, .dmg, .pkg, .exe with JRE included.
But I need build same files without JRE bundled.
Sure, I can use JAR, but I want to make my own icon and maybe installer.
I also tried to create .app folder from jar to execute it manually "java -jar myJarName.jar" , but if I have several JDK version - it always uses the latest (JRE 11) which not included javaFX library and my .app doesn't work. But if I run the same JAR with Jar Launcher.app it works perfectly. Somehow it chooses the right jre version.
ExcelsiorJet, install4j and similar apps work well, but my project is OpenSource and I can not pay 3000$ for this.
The question is - how can I build MacOs/Windows native launcher app/dmg/pkg/exe without JRE bundled for users who already have JRE installed? Can I use IntelliJ IDEA to build this a way as I built with jre bundled?
java bash javafx jar
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I built in IntelliJ IDEA my javaFX application as jar file.
Using "Project Structure >> Artifacts >> + JavaFX Application" I can build .app, .dmg, .pkg, .exe with JRE included.
But I need build same files without JRE bundled.
Sure, I can use JAR, but I want to make my own icon and maybe installer.
I also tried to create .app folder from jar to execute it manually "java -jar myJarName.jar" , but if I have several JDK version - it always uses the latest (JRE 11) which not included javaFX library and my .app doesn't work. But if I run the same JAR with Jar Launcher.app it works perfectly. Somehow it chooses the right jre version.
ExcelsiorJet, install4j and similar apps work well, but my project is OpenSource and I can not pay 3000$ for this.
The question is - how can I build MacOs/Windows native launcher app/dmg/pkg/exe without JRE bundled for users who already have JRE installed? Can I use IntelliJ IDEA to build this a way as I built with jre bundled?
java bash javafx jar
I built in IntelliJ IDEA my javaFX application as jar file.
Using "Project Structure >> Artifacts >> + JavaFX Application" I can build .app, .dmg, .pkg, .exe with JRE included.
But I need build same files without JRE bundled.
Sure, I can use JAR, but I want to make my own icon and maybe installer.
I also tried to create .app folder from jar to execute it manually "java -jar myJarName.jar" , but if I have several JDK version - it always uses the latest (JRE 11) which not included javaFX library and my .app doesn't work. But if I run the same JAR with Jar Launcher.app it works perfectly. Somehow it chooses the right jre version.
ExcelsiorJet, install4j and similar apps work well, but my project is OpenSource and I can not pay 3000$ for this.
The question is - how can I build MacOs/Windows native launcher app/dmg/pkg/exe without JRE bundled for users who already have JRE installed? Can I use IntelliJ IDEA to build this a way as I built with jre bundled?
java bash javafx jar
java bash javafx jar
edited Nov 11 at 5:35
asked Nov 10 at 19:30
Iga
335
335
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Okay, looks like I found some crooked way to do this all.
Windows solution:
To bundle on Windows it's easy to use launch4j (windows only). It's free and there is no problem to create .exe with no Jre bundled.
MacOS solution:
For MacOS it's a bit harder:
Create myApplication.app folder and design it's structure
- Write launcher bash script:
In my case I should detect which versions of Jre installed and choose any between java 1.8 and 10
I don't know bash script language and I believe I write it unoptimized way. I would be happy if anyone correct me. Anyway it works the way as I wanted:
#!/bin/sh
# set the working directory
DIR=$(cd "$(dirname "$0")"; pwd)
# extract first fit java version installed
jre_path=$(/usr/libexec/java_home -V 2>&1 |
while IFS= read -r line
do
if [[ "$jre_found" == "true" ]]; then
break
fi
version=$(echo $line | cut -d ' ' -f 1|sed 's/^ *//;s/ *$//' | cut -d ' ' -f 1 | sed 's/^ *//;s/ *$//')
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
array=($line// /)
array_size=$#array[@]
let "last_index=array_size-1"
path=$array[ $last_index ]
if [[ $major == 1 ]]; then
if [[ $minor -gt 7 && $minor -lt 11 ]]; then
echo $path
jre_found="true"
fi
elif [[ $major -gt 7 && $major -lt 11 ]]; then
echo $path
jre_found="true"
fi
done)
# execute our jar file
$jre_path/bin/java -jar "$DIR"/myApp.jar
And now everything should be working from double click on myApplication.app.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Okay, looks like I found some crooked way to do this all.
Windows solution:
To bundle on Windows it's easy to use launch4j (windows only). It's free and there is no problem to create .exe with no Jre bundled.
MacOS solution:
For MacOS it's a bit harder:
Create myApplication.app folder and design it's structure
- Write launcher bash script:
In my case I should detect which versions of Jre installed and choose any between java 1.8 and 10
I don't know bash script language and I believe I write it unoptimized way. I would be happy if anyone correct me. Anyway it works the way as I wanted:
#!/bin/sh
# set the working directory
DIR=$(cd "$(dirname "$0")"; pwd)
# extract first fit java version installed
jre_path=$(/usr/libexec/java_home -V 2>&1 |
while IFS= read -r line
do
if [[ "$jre_found" == "true" ]]; then
break
fi
version=$(echo $line | cut -d ' ' -f 1|sed 's/^ *//;s/ *$//' | cut -d ' ' -f 1 | sed 's/^ *//;s/ *$//')
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
array=($line// /)
array_size=$#array[@]
let "last_index=array_size-1"
path=$array[ $last_index ]
if [[ $major == 1 ]]; then
if [[ $minor -gt 7 && $minor -lt 11 ]]; then
echo $path
jre_found="true"
fi
elif [[ $major -gt 7 && $major -lt 11 ]]; then
echo $path
jre_found="true"
fi
done)
# execute our jar file
$jre_path/bin/java -jar "$DIR"/myApp.jar
And now everything should be working from double click on myApplication.app.
add a comment |
up vote
1
down vote
accepted
Okay, looks like I found some crooked way to do this all.
Windows solution:
To bundle on Windows it's easy to use launch4j (windows only). It's free and there is no problem to create .exe with no Jre bundled.
MacOS solution:
For MacOS it's a bit harder:
Create myApplication.app folder and design it's structure
- Write launcher bash script:
In my case I should detect which versions of Jre installed and choose any between java 1.8 and 10
I don't know bash script language and I believe I write it unoptimized way. I would be happy if anyone correct me. Anyway it works the way as I wanted:
#!/bin/sh
# set the working directory
DIR=$(cd "$(dirname "$0")"; pwd)
# extract first fit java version installed
jre_path=$(/usr/libexec/java_home -V 2>&1 |
while IFS= read -r line
do
if [[ "$jre_found" == "true" ]]; then
break
fi
version=$(echo $line | cut -d ' ' -f 1|sed 's/^ *//;s/ *$//' | cut -d ' ' -f 1 | sed 's/^ *//;s/ *$//')
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
array=($line// /)
array_size=$#array[@]
let "last_index=array_size-1"
path=$array[ $last_index ]
if [[ $major == 1 ]]; then
if [[ $minor -gt 7 && $minor -lt 11 ]]; then
echo $path
jre_found="true"
fi
elif [[ $major -gt 7 && $major -lt 11 ]]; then
echo $path
jre_found="true"
fi
done)
# execute our jar file
$jre_path/bin/java -jar "$DIR"/myApp.jar
And now everything should be working from double click on myApplication.app.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Okay, looks like I found some crooked way to do this all.
Windows solution:
To bundle on Windows it's easy to use launch4j (windows only). It's free and there is no problem to create .exe with no Jre bundled.
MacOS solution:
For MacOS it's a bit harder:
Create myApplication.app folder and design it's structure
- Write launcher bash script:
In my case I should detect which versions of Jre installed and choose any between java 1.8 and 10
I don't know bash script language and I believe I write it unoptimized way. I would be happy if anyone correct me. Anyway it works the way as I wanted:
#!/bin/sh
# set the working directory
DIR=$(cd "$(dirname "$0")"; pwd)
# extract first fit java version installed
jre_path=$(/usr/libexec/java_home -V 2>&1 |
while IFS= read -r line
do
if [[ "$jre_found" == "true" ]]; then
break
fi
version=$(echo $line | cut -d ' ' -f 1|sed 's/^ *//;s/ *$//' | cut -d ' ' -f 1 | sed 's/^ *//;s/ *$//')
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
array=($line// /)
array_size=$#array[@]
let "last_index=array_size-1"
path=$array[ $last_index ]
if [[ $major == 1 ]]; then
if [[ $minor -gt 7 && $minor -lt 11 ]]; then
echo $path
jre_found="true"
fi
elif [[ $major -gt 7 && $major -lt 11 ]]; then
echo $path
jre_found="true"
fi
done)
# execute our jar file
$jre_path/bin/java -jar "$DIR"/myApp.jar
And now everything should be working from double click on myApplication.app.
Okay, looks like I found some crooked way to do this all.
Windows solution:
To bundle on Windows it's easy to use launch4j (windows only). It's free and there is no problem to create .exe with no Jre bundled.
MacOS solution:
For MacOS it's a bit harder:
Create myApplication.app folder and design it's structure
- Write launcher bash script:
In my case I should detect which versions of Jre installed and choose any between java 1.8 and 10
I don't know bash script language and I believe I write it unoptimized way. I would be happy if anyone correct me. Anyway it works the way as I wanted:
#!/bin/sh
# set the working directory
DIR=$(cd "$(dirname "$0")"; pwd)
# extract first fit java version installed
jre_path=$(/usr/libexec/java_home -V 2>&1 |
while IFS= read -r line
do
if [[ "$jre_found" == "true" ]]; then
break
fi
version=$(echo $line | cut -d ' ' -f 1|sed 's/^ *//;s/ *$//' | cut -d ' ' -f 1 | sed 's/^ *//;s/ *$//')
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
array=($line// /)
array_size=$#array[@]
let "last_index=array_size-1"
path=$array[ $last_index ]
if [[ $major == 1 ]]; then
if [[ $minor -gt 7 && $minor -lt 11 ]]; then
echo $path
jre_found="true"
fi
elif [[ $major -gt 7 && $major -lt 11 ]]; then
echo $path
jre_found="true"
fi
done)
# execute our jar file
$jre_path/bin/java -jar "$DIR"/myApp.jar
And now everything should be working from double click on myApplication.app.
edited Nov 12 at 0:44
answered Nov 11 at 5:15
Iga
335
335
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242661%2fpackaging-jar-file-for-mac-and-windows-without-jre-bundled%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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