I need to create a .exe file for my project. I have a launcher and 5 applications. Applications are launched using the launcher applications. How can I collect the entire project into 1 executing file and run it using it? My project built on Gradle.
What are the ways to solve my problem?
The recommended way to do this for modern JavaFX applications is to use jpackage which comes with JDK 14. Don't try executable jars. They won't work in general.
If you have to, you can use JDK 14+ just for jpackage but bundle your app with any JDK 11+. Just have a look here for a tutorial: https://github.com/dlemmermann/JPackageScriptFX
Try using Launch4J (http://launch4j.sourceforge.net/) or Advanced Installer (https://www.advancedinstaller.com/) to package your .jar files into a single (or multiple) .exe file(s). Note that these are third-party programs which will enable you to package your .jar files and deploy most probably on your client's computer.
For more info read,
https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html
https://www.genuinecoder.com/convert-java-jar-to-exe/
Related
I'm trying to bundle my jar file with a jre into an executable on mac so that users using my application don't need to have java installed on their machine. I'm using IntelliJ's built-in tool that automatically bundles the jar file into a platform specific package but whenever I try to build the artifact I get an error message of
jpackage: No archive found
I was able to create a bundled .exe file with the jar file on windows using launch4j but that tool can't create mac executables (unless I'm mistaken) and it would probably be more convenient to learn how to use the IDE to do it for me.
I can't seem to find out what it is I'm doing wrong, nor can I find anything online about this error message. Any suggestions? (I'm using java 16)
I was able to fix this problem by deleting and re-doing the configuration for the package artifact build. Everything worked smoothly afterwards
I want to run a java program as an exe in Windows. The windows box doesn't install java at all...
So, is there any other way in which the java program can be converted to an exe which removes the need for a dependency on the JRE?
You can use Excelsior JET compiler for that purpose.
See http://www.excelsiorjet.com/ for more information on this.
You can ship the JRE with your application and use that JRE for your application. The effect is the same: The application will be started through an executable (wrapper needed) or script (batch) file and the target machine does not need to have a java runtime installed.
Java doesn't have to be 'installed', it just has to be 'present'.
For the application to run you will need the runtime. In fact the very first thing that happens when you start the app is a call is a made to OS to start JRE. You cannot do without JRE.
[You can of course embded JRE into your app itself if you want].
I have used JSmooth to exify my application. It also allows for embedding a JRE inside. I just used the "ensure that at least Java X is available".
GPL, can be run as an ant task.
Well given the fact, that you are requesting an executable file (exe) in Windows, there is another approach:
Use IKVM.NET - Bytecode Compiler which converts Java bytecode to .NET dll's and exe's.
Get the latest version of IKVM.NET here.
Use this command
ikvmc -target:exe -out:foo.exe yourJarFile.jar
to create your .NET executable file.
After this, you can use your exe with the mandatory IKVM dll's or if you prefer one exe file, you can use ILMerge in order to get a single executable file:
ILMerge.exe /target:winexe /targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1" /out:C:\foo\bar.exe foo.exe <IKVM dll's>.dll
If you are using JDK 9 and above then you can use jlink. It will include all the necessary modules, header files, security policy files, etc, and build a minimal runtime image. This image can be shipped directly to the customer. You can specify your own launcher and what not.
jlink description:
You can use the jlink tool to assemble and optimize a set of modules and their dependencies into a custom runtime image.
Read more at oracle docs: Java Platform, Standard Edition Tools Reference.
GCJ can create native code from Java source files. Here's a tutorial on how to build it in Windows.
Have you tried install4j? There are various versions, some free, of this concept. Basically, this application compiles your application into an executable installer, specific to the OS of your choice.
Easiest way to do this task is to use the launch4j for the windows exe wrapper and then use inno setup to create the installer. When you are creating the installer for the you application add the folder under the other application files. Make sure jre is inside the folder.
Work done!!!
Is there a way to bundle a spring-boot application into one executable jar including a JRE?
I think I saw someone doing that (Josh Long?) which resulted in a jar you could start via java -jar foo.jar and even with ./foo.jar
I googled for this the last hour but couldn't find any documentation on this, anyone there to help me out?
EDIT:
I just found what I saw at the conference. spring-boot 1.3 introduces something called executable jars, which wrap the jar with a shell script.
Enabling this makes it possible to run your jar like ./my.jar and tying it to an unix init system.
However, you still need java installed at your host.
Enabling this feature in gradle is as easy as adding this to your build.gradle
springBoot {
executable = true
}
You should think about using a Java installer / wrapper which will create a native binary which contains your code / jar and the JRE (some solutions can even download a JRE for you)
The positive side effect is that you (if needed) can create solutions for Linux, Windows and Mac.
If you want to stick to a simple Linux only solution you might want to try this: Bash script containing binary executable
Propably you are using Maven. This maven plugin allows you to create single jar file with all dependencies. Next you can use tool such as jwrapper which allows to build executable file with embeded JRE for many platforms.
I have to create a jar file wherein i need to add external jar files in the classpath, properties files, in such away as to run it on any other machine.
You could either use manifest.mf to define external class path or use script that composes classpath and runs your application.
I really recommend you to use a build tool such as Maven for these things:
http://maven.apache.org/
How can I create an executable JAR with dependencies using Maven?
Regards,
Boskop
You can make the jar in almost any IDE. I agree with Michael SchmeiBer, be a bit more specific please.
I use eclipse as my IDE (because you can both use it in windows and Ubuntu Linux) to make a jar (you can define the startup class in the jar).
I use different methods for starting up of different machines.
I use nsis to create a nice windows executable (.exe) You can include your own icon.
In nsis script you actually use the same command you would use in a batch command.
nsis has some nice features, like search for a java jre.
For Linux and Mac I use a .sh file with this command.
I have the following jar files for my app:
DesktopApplication1.jar
Plus , i have used the some extra API's for my app , like jsoup, jexcelapi etc. There are about 7 api's in the lib folder.
How to make a EXE file & RPM file out of all these jar files?
P.S. I am a first timer. So take that into consideration.also, I have used Netbeans 6.8. So the main API is in \dist folder. And the API used is in \dist\lib folder.
thanks in Advance
use jsmooth to make exe from jar
Build your JAR with fatJar to include all the dependencies in it, and then make it executable with your favorite tool (I use Launch4j)
RPM is little bit different, since it is not executable, but package format. There are lots of tutorials, how you build it up.
You could make a BAT file a file with .bat(For windows) extension
Just open notepad and write the following text
java -jar DesktopApplication1.jar
Save the file as filename.bat(the .bat extension is important)
Place the .jar and .bat files together and just double click the .bat file every time you need to run the jar...
If you don't want to keep both together then give the absolute path of the jar in the .bat file
java -jar AbsolutePath/DesktopApplication1.jar
For a linux machine make a file with (.sh) extension rest of the procedure is same...
Try InstallJammer. It provides what you want.
Deploy the app. with Java Web Start. JWS Can make it easy to add other Jars to the apps. run-time class-path, avoiding the common problem with fat jar of violating the API's distribution license (when it says WTE 'you are allowed to distribute this in unaltered form..') and can provide the further benefit of only downloading the parts that the user requires (when the user requires them).
JWS has many other cool features like desktop integration (menu bars, start menu item), splash screens, automatic updates, support by the owners of Java, and compatibility with any platform for which Java is available.
For creating .exe to run on Windows:
Download launch4j from http://launch4j.sourceforge.net.
build wrapper .exe through launch4j.
Download innoSetup from http://www.jrsoftware.org/isdl.php.
Build .exe as installer, the setup file, for user to download and install.
Install rpm for linux:
If your application used other native libraries, you need to download and install Linux native libraries. This is how we build rpm for our app.