Is it possible to create an .exe executable file using Java? - java

I am not talking about the executable jar file, instead the .exe file for windows can that be generated for Java apps. I know there is some projects like JSmooth etc., so I am a little curious to know how they create exe's for jar or class files.

Why not write a .bat file (windows script) that launches the executable jars? The effect will be the same: user double-clicks and launches the app.

Related

How to execute .exe from within runnable jar file

I am working on a Java desktop application and want to execute an .exe file upon some user action.
I want to package the .exe inside the executable jar so that I have to ship just one item to my customer/user. But so far I have not been able to execute an .exe file which is packaged inside the jar.
One more input, the .exe in turn uses a bunch of .dll, .xml and .exe files (total 12 files), so I need to package all of them to make this work. Is this possible in java or should I use another language to achieve this?
I chose java because I want to support Mac platform also. So with these .exe and .dll files (for Win), I need to package and execute a bunch of Unix executable files and dylib files also (for Mac).
What would be the best way to achieve this?
I can think of 2 ways:
Make one Java executable app and dynamically execute exe or Unix executable file depending on platform it is running. The problem here is executing the files which are packaged within the jar.
Make separate applications for Win and Mac. In this case, which languages should I use?
Thanks much for the help!
Applications are packaged very differently on windows and mac. For the Windows version I would recommend you to distribute an installation program (see IzPack for instance) that will unpack the jar and the exe in the application directory (I don't believe you can directly execute an exe that's in a jar file). A MacOS application is actually a directory with a certain structure, so in your case, the said directory could contain both the jar and the exe.

How to create executable .exe file from .jar file? [duplicate]

This question already has answers here:
How can I convert my Java program to an .exe file?
(16 answers)
Closed 6 years ago.
I've created an app using netbeans IDE but it is in .jar format.How do I convert it into .exe to use on individual system ?
many responses here:
Compiling a java program into an executable
JSmooth .exe wrapper
JarToExe 1.8
Executor
Advanced Installer for Java - tutorial for Java applications
GCJ
Launch4J: http://launch4j.sourceforge.net/
If you need to just create a runnable file of your application, the JAR should be enough to do the job. You can export it as an executable jar with the manifest file and run it just by double cliking it.
Still if you require an exe, then you can use Launch4J. To create an exe, create jar file for your application using your IDE with proper MANIFEST file packaged inside. Then launch Launch4J and select your jar file and you should be able to create an exe easily.
For more details, take a look at this link here
You can use launch4j this can make jar an exe

How can I make an executable file with java netbeans?

How can I make an executable file with Java using NetBeans IDE that file work on computer or mobile. I create jar file but I don't know why it did not work.
You can run jar file in case its manifest contains proper reference to class with main() function using command java -jar jarfile.jar. If you need Windows executable, you can use launch4j. For Android AFAIK you need to build apk file.

How to make a Java program be opened by default with Java, on any computer

When I send Java games I created to friends, the JAR file I send them often looks like a RAR file to them. This is because Windows on their computers thinks this file should be opened by WinRar.
They have JRE on their computers, but the default on Windows is that the file they recieve should be opened by WinRar.
The people I send my program can't be expected to guess, that what they need to do is specifically tell Windows to open the file with Java.
Is there a way to make it so that a JAR file I send to somebody, will be opened on his/her computer by default using the JRE?
Thanks a lot
You can consider adding a BATCH script.
Something like java -jar YourJarName.jar
You will need two of them - for unix and windows:
Windows start.bat:
java -jar YourJarName.jar
Unix start.sh:
#!/bin/bash
java -jar YourJarName.jar
You could use a tool such as Launch4J to wrap the JAR file into an executable.
You can convert your JAR file to executable file using Java Launcher.
OR
As #lan Roberts answer You can use Launch4j to wrap your JAR to executable. You can download it from this.

How to export my java program and open it in other computers? (Using Eclipse)

Is there any .exe file like those VB creates for you which can be opened in different computers without any other app? created or can be created by Eclipse? I didn't find a thing in the project folder.
Java uses the "jar"-files as a container for executable binaries. But they require Java beeing installed on the target computer.
In Eclipse you can export you application via File -> Export -> Runnable JAR file
Then you have to select the entry point (a class with a main-method) which should be called on running the jar-file.
On the target computer you can normally run the jar file by double-clicking it (Java SE is required to be installed). When that doesn't work you can manually call "java -jar container.jar" to execute the jar in the Java enviroment.
Jar files are used for deployment but in order to run them you need the jvm.
You can convert jar files to .exe .
I'm not sure if the conversion will result in the app running on computers with different OS'es (probably not) than the one in which the the .exe program was created in.
Here are some references
How to create an exe file in java.
How can I create a Windows .exe(standalone executable) using Java/Eclipse?.

Categories