How can I make a program executable by double clicking? [duplicate] - java

This question already has answers here:
How to make an executable JAR file?
(5 answers)
Closed 8 years ago.
I wrote a JAVA program for my wife to compare coupons stacked with sales on different item sizes to save her time on her shopping-trip-planning. Now I need to put it on her computer in such a way that she can double-click something, and have the program run. I'm not finding anything good on the interwebs (like a decent step by step).
It is a simple program, one class with a nested class, and various imports of swing, awt, and text.
Since it's my wife's computer, I can make sure that she is running the appropriate JRE. Thanks in advance for any help.

You can use Launch4j application. That convert executable jar file to windows native executable application.
You can also embed JRE with it so if JRE is not installed on machine the application will run.
you can also add some other mechanism to it also like loading image, icon, etc.

I assume you are using Eclipse. In this website they given it very clearly for eclipse.
Create Executable files in eclipse

Export it to (or create a) executable Jar.
Most IDE's will do this (I think you have to dig around Eclipse a little) or take a look at Packaging Programs in JAR Files and Setting an Application's Entry Point if you want to do it by hand
Most GUI OS's will run the Jar via a double click.
You could also investigate generating a native executable wrapper, which will make the program "look" more familiar to the user, including launch4j or exe4j or Packaging a Java App for Distribution on a Mac depending on your target platform

Use NetBeans and simply 'Build' the jar file. This will produce an executable file within the 'dist' folder of your project.
Eclipse is the same however slightly more hidden.

Related

Intellij JavaFX vs Java Project for .exe file [duplicate]

This question already has answers here:
How can I convert my Java program to an .exe file?
(16 answers)
Closed 3 years ago.
I have already a Java Project in Intellij.
I want to make a .exe Java file, but I did not find any solution yet for Java Projects. On the other hand, I have found many youtube videos in which they use a JavaFX Project to create an artifact which they will use to create a .exe file.
One of them is the following youtube video:
IntelliJ export JavaFX application to exe on Windows
My end goal is, that a user just double clicks on the file and a GUI opens. After entering some information the rest of the code should run. The file should be able to run to different windows systems, so this should not only work when installing special packages.
Did I chose the wrong type of project? To that I just read, that JavaFX will be discontinued.
I am confused in so many levels...
You should first make an executable .jar file and then use an .exe wrapper on the jar. I've used
Launch4j in the past with great success. I haven't tried it on javafx yet, but there are many executable wrappers to choose from with a quick google search. If this is at all unclear, leave a comment, and I'll detail these steps more. Launch4j has an almost self explanatory interface, so I don't think you should have trouble as long as you're sure your .jar launches.
What you're looking for is an executable jar file I think. I know that eclipse you can generate one so I'd assume you can do the same in intellij. How to

Java Executable Application [duplicate]

This question already has answers here:
How to make an executable JAR file?
(5 answers)
Closed 5 years ago.
I am an amateur Java programmer, and I have just started learning how Java applets work. However, I wanted to make an applet for my Chrome browser, but it no longer works because Chrome doesn't support NPAPI plugins (like Java and Unity 3D). I want to make a standalone Java executable similar to Minecraft. The idea is that once I double-click on the .jar file, it opens the application and runs the program.
The program displays text and images based on input from a text box.
How do I make the .jar automatically open on a double click?
To make a JAR which can be launched by double clicking, you have to make it an executable JAR. There must be a file META-INF/MANIFEST.MF inside the JAR with key-value pairs that point to the main class (the class with the main method) to run.
See Lesson: Packaging Programs in JAR Files in Oracle's Java Tutorials to learn exactly how to create an executable JAR.
No.
After the release of Chrome version 45, you’ll need to use an alternate web browser to load content that requires a NPAPI plugin.
But you can create application using Java Network Programming will help to create the application.

Easy way to make a runnable program out of a java project

Im doing a small Java project with some school kids to teach them programming and at the end of this project hopefully we will have a small Game.
I would like to give these kids some sort of "exe" file(on an USB-Stick) that should run if you double click it.
I can produce a .jar file, but that wont execute on double clicking it.
The first thing i can think of is a .bat file with java -jar [game.jar] as content but this would require an installed JRE.
Is there any better(but not too complex) way to generate a file(or directory with file in it) that could run anywhere(on Windows is enough) like a portable JRE?
The best solution would be a single File like a self-extracting zip.
You can use Launch4j, it makes an .exe which tries to run the program and if no JRE is found it leads them to the download page of the JRE. I'm just not sure if it can make an .exe with embedded JRE.
Their website: http://launch4j.sourceforge.net/
Because you are using Java, which is dependent on the JRE to run, you are not going to get around not having the JRE installed without significant legwork. Just package instructions with the flash drives you give the kids!
If you're committed though, look into http://www.excelsiorjet.com/ or http://www.duckware.com/jexepack/index.html.
As well as this SO question: How can I convert my Java program to an .exe file?
I can produce a .jar file, but that wont execute on double clicking it.
Why doesn't this work? Is it an issue with having a JRE present, and that these kids might not have it, or might not be able to install it on other's machines?
I suggest you go here if you want go the "exe" route.
http://www.excelsiorjet.com/free
if you click "free licenses" you can get apply for a free license of I believe the "standard edition."
This should be "Good enough" for your intended purposes, and you wont need a JRE present.
It's more work on your end, but it should work nicely for your needs.

Eclipse jar to an exe?

I've searched far and wide, I can create my JAR using eclipse but when I run it, it doesn't run half of the program because it didnt import the API's, because the API's don't exist in the JAR.
I made a simple pac-man game (still learning java :O)
I compiled it into an executable JAR so I could use a program called 4J to turn it into an exe!
However, the JAR doesn't even run the game :/
Don't know what sources you need, so just ask.
Sorry I'm a newb D:
You can supply third-party API within your jar file. This is so called fat jar approach (all classes will be put into one jar according to names of the packages). So you will deal with one jar file (then convert it to exe, or add shell scripts for specific operating systems which will just run java -jar game.jar - too many options).
As for Eclipse search for specific plugins. Or, as mentioned above, use Maven or tool that will give you a portable installer. It's completely up to you.

Create executable package for a netbeans project [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Export JAR with Netbeans
I have created a NetBeans Project and now I want to create a package from the project. As this is my first project in NetBeans. Can any one help me to create a package from my project for distribution?
Expanding on the question for the .exe:
I have good experience using Winrun4J to generate an exe launcher for my Java applications. It's quite forward to setup and generate and it supports 32 and 64 bit Windows.
You can even put all needed jars into the exe.
http://winrun4j.sourceforge.net/
But (as you seem to be new to Java): the exe is only a wrapper. It still requires a Java Runtime to be installed on the system where you start the exe!
If you have several project in development environment, make sure you have set the project you want to distribute as a main project. It can be done via mouse right click menu on project name in the left pane.
Click on menu: "Run -> Clean and build main project"
Inspect your project folder, find folder dist in your project folder. There is *.jar file. It is packaged compiled project file.
If you want to code desktop apps. that will run on Windows, OS X & *nix, write them in Java & deploy them from a link using Java Web Start.
JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or Java version, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..
I high-lit the part that is relevant to your next comment.
can I give my own icon image to the executable file?
Why should the user ever see a .jar (or a .exe for that matter)? JWS offers desptop integration, which might consist of a desktop shortcut and/or menu item on supported OS'. Either of those can have an image (within limitations) as supplied by you.
The deployJava.js script checks the user has the required minimum version (helps them to install it, if not), before running an applet or providing a link to a JWS app.

Categories